工作常用结构伪类选泽器
一.:nth-child(n)获取到选中结构中第n个元素eg1: /* 表示选中了box盒子里面所有的li中的指定的位置的元素 */ .box li:nth-child(3) { background-color: powderblue; }
eg2:n可以直接取even,odd或者(2n,2n+1)选取结构奇偶部分
二.:first-child,last-child,可以选取结构第一个和最后一个
eg: /* 表示选中了box盒子里面所有的li中的第一个 */ .box li:first-child { background-color: palegreen; }
三.属性选择器 **元素名称[相关属性] { css样式 }**
eg1: /* 表示选中了input标签,而且标签有一个type属性 */ input[type] { background-color: blueviolet; }
eg2: /* 表示选中了input标签,而且标签有一个type属性,属性的取值为url */ input[type=url] { background-color: green; }