Home > Web Front-end > CSS Tutorial > How to select the nth child element using css attribute nth-child(n) matching

How to select the nth child element using css attribute nth-child(n) matching

不言
Release: 2018-06-21 16:39:33
Original
2606 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template