css3伪类选择器的几种写法介绍

html-css05

css3伪类选择器的几种写法介绍,第1张

一、X:nth-child(n) li:nth-child(3) {color: red}接下来的几个伪类选择器使用上非常类似,功能也比较接近。:nth-child(n),用于匹配索引值为n的子元素。索引值从1开始。X:nth-child()用法实际上有三种变化,demo的用法是最简单的,X:nth-child()更强大的用处在于奇偶匹配,明河不展开讲,有兴趣的请看《Understanding :nth-child Pseudo-class Expressions》,《CSS3 :nth-child()伪类选择器》 二、X:nth-last-child(n) li:nth-last-child(2) {color: red}:nth-child(n),是从第一个开始算索引,而X:nth-last-child(n)是从最后一个开始算索引。

@media screen and ( (max-width: 480px){

.item1,.item2{height:200px}

}

@media screen and (min-width: 481px) and (max-width: 760px){

.item1,.item2{height:300px}

}

@media screen and ( (min-width: 76px){

.item1,.item2{height:400px}

}