This article mainly introduces how to use the css attribute nth-child(n) to match and select the nth child element. It has a certain reference value. Now I share it with you. Friends in need can refer to it
css matching selects the nth child element. You can use the :nth-child(n) selector, which matches the Nth child element belonging to its parent element, regardless of the type of the element.
Add to make the second th 50% of the total width of the table.
<style type = "text/css"> table tr th:nth-child(2) </style> <table> <tr> <th>第一个</th> <th>第二个</th> <th>第三个</th> </tr> </table>
Definition:
:nth-child(n) The selector matches the Nth (n) element that belongs to its parent element (here, tr) Here select the 2nd) child element (here the child element is th), regardless of the type of element.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About how to use the table-cell attribute in CSS
How to use CSS pointer- The events attribute implements the mouse penetration effect
#
The above is the detailed content of How to select the nth child element using css attribute nth-child(n) matching. For more information, please follow other related articles on the PHP Chinese website!