(四)伪类选择器
3.都有哪些呢?
1):超链接伪类
2)结构伪类
e. :nth-last-child(n)
这个选择器跟上上一个差不多,只不过是从后往前数
比如
<body>
<main>
<article>
<h1>第一行</h1>
<h1>第二行</h1>
<h1>第三行</h1>
<h1>第四行</h1>
<h1>第五行</h1>
<h1>第六行</h1>
</article>
</main>
</body>
<style>
article :nth-last-child(1){
color: red;
}
</style>
也可以写公式,比如-n+2,其实用法和:nth-child(n)是一毛一样。
<style>
article :nth-last-child(-n+2){
color: red;
}
</style>
依然有:nth-last-of-type(n)区别种类的,就不多说了。
f :not(selector)
not,不要,不要,不要,很明显这个是排除选择器。选择那些不想要的
(注意:选择器是可以多个一起用的,但是用的时候冒号:和前一个选择器之间不要有空格,否则不好使的哦!别问我怎么知道的。)
article :nth-child(n):not(:nth-child(2)){
color: red;
}
</style>