css3 相关伪类

1、:not()类似jQuery中的 :not()选择器,主要用来定位不匹配该选择器的元素。其用途还是很强大的,

举2个例子:

:not(footer){
    border:1px solid black;/*表示选择页面中所有元素,除了footer*/
}
input:not([type=submit]){
    ... /*给表单中所有input定义样式,除了submit按钮*/
}
2、 :nth-of-type与:nth-child的区别
<div class="post"> 
    <h1>标题</h1>
    <h2>副标题</h2>
    <p>第一个段落</p>
    <p>第二个段落</p>
</div>

.post>p:nth-child(2){color:red}
.post>p:nth-of-type(2){color:red}

:nth-child( )选择的是某父元素的子元素,这个子元素并没有确切的类型;

:nth-of-type( )选择的某父元素的某子元素,这个子元素是指定的类型

猜你喜欢

转载自blog.csdn.net/sinat_29729453/article/details/80338716