Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
1.子元素:>
2.后代元素: 空格
3.相邻兄弟:+
4.所有兄弟:~
<div class="a">
<h1 id="b" class="c">hello world</h1>
</div>
div {
background-color: red;
width: 200px;
}
div > h1 {
color: blue;
}
div {
background-color: red;
width: 200px;
}
div > h1 {
color: blue;
}
div > h1 {
color: cyan;
}
div {
background-color: red;
width: 200px;
}
div > h1.leteracy {
color: blue;
}
div > h1 {
color: cyan;
}
在样式后加 !important 从而忽略样式的权重
div {
background-color: red;
width: 200px;
}
div > h1.leteracy {
color: blue;
}
div > h1 {
color: cyan !important;
}
<ul class="list">
<li class="item1">item1</li>
<li class="item2">item2</li>
<li class="item3">item3</li>
<li class="item4">item4</li>
<li class="item5">item5</li>
<li class="item6">item6</li>
<li class="item7">item7</li>
<li class="item8">item8</li>
<li class="item9">item9</li>
<li class="item10">item10</li>
<li class="item11">item11</li>
<li class="item12">item12</li>
<li class="item13">item13</li>
<li class="item14">item14</li>
<li class="item15">item15</li>
</ul>
ul {
width:100px;
background-color: black;
}
ul>li {
color:aqua;
background-color: violet;
}
ul {
width:100px;
background-color: black;
}
ul>:nth-of-type(n) {
color:aqua;
background-color: violet;
}
:nth-of-type(an+b):
a=[0,1,2….]
n=[0,1,2,….]
b为偏置量
如 -n+3 :
-n | result |
---|---|
0 | 5 |
-1 | 4 |
-2 | 3 |
-3 | 2 |
-4 | 1 |
忽略 =< 0 的数字
即改变前五个的样式
将其改成:nth-last-type-(an+b):一样的参数就会变成后五个
又如:
:nth-of-type(-2n+15)
-n | -2n+15 |
---|---|
0 | 15 |
1 | 13 |
2 | 11 |
3 | 9 |
4 | 7 |
5 | 5 |
6 | 3 |
7 | 1 |