I have used multicolumn and tabularx for the table I intend to write in LaTex. But the resultant table is going out of the page width. I also added the textwidth in tabularx but it is not working as desired. Surely, I have did some mistake but cant figure out. Would be glad to have the correction. Thank you
\begin{table}
\centering
\caption{my table}
\label{mytable}
\begin{tabularx}{\textwidth}{|c|c|c|c|X|c|X|}
\hline
\multicolumn{1}{|l|}{Type} & \multicolumn{1}{l|}{Product name} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Diameter\\(mm)\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Tensile strength\\(MPa)\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Young's modulus\\(GPa)\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Elongation\\(\%)\end{tabular}} & Application \\
\hline
\multirow{5}{*}{\begin{tabular}[c]{@{}c@{}}class A\\~\\~\\~\\ \end{tabular}} & abc123 & 0.014 & 1500 & 36 & 7 & four words text here \\
\cline{2-7} & abc123 & 0.040 & 1400 & 36 & 6.5 & four words text here\\
\cline{2-7} & abc123 & 0.20 & 975 & 27 & 9 & four words text here \\
\cline{2-7} & abc123 & 0.31 & 975 & 26 & 6 & four words text here \\
\cline{2-7} & abc123 & 0.67 & 900 & 23 & 9 & four words text here \\ \hline
\multicolumn{1}{|l|}{\multirow{3}{*}{class B}} & abc123 & 0.027 & 1560 & 39 & 6.5 & four words text here \\
\cline{2-7} \multicolumn{1}{|l|}{} & abc123 & 0.040 & 1600 & 41 & 6.5 & four words text here \\
\cline{2-7} \multicolumn{1}{|l|}{} & abc123 & 0.10 & 1200 & 28 & 12.5 & four words text here \\
\hline
\end{tabularx}
\end{table}
Also, the merged column text of the first column, I want it to set the vertical alignment to center instead of top.