<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
All of the following examples are based on the code above.
1: Select all other elements that are not in the child element except the first one
A:ul Li:not (: first-child) {
Background:gray;
}
B:ul li:first-child~*{
Background:gray;
}
Based on the expansion of the first way, we can choose to remove the style of the other elements of any one element
For example I would now like to select other elements in addition to the third element: UL Li:not (: Nth-child (3)) {colro:red}
If you want to choose a style for the first three elements:
UL Li:nth-child (-n+3) {
font-size:30px;
}
Because N is a range, [0, Infinity], and here is-N, so the interval is (infinity, 0], because of n+3, so we choose the range is (infinitesimal, 3], because nth-child from 1 to start retrieving, so chose the three-way
If you want to select the second three elements
UL Li:not (: Nth-child (-n+2)) {
}
The use of Nth-child