css3新增结构选择器(css3新增选择器有哪些)
导读:随着CSS3的不断发展,越来越多的新特性被引入。 其中最重要的之一就是新增的“结构选择器”。/* 选择器1:E:nth-child(n */div:nth-child(2 {/* 样式 */}/* 选择器2:E:first-child...
随着CSS3的不断发展,越来越多的新特性被引入。 其中最重要的之一就是新增的“结构选择器”。
/* 选择器1:E:nth-child(n) */div:nth-child(2) { /* 样式 */} /* 选择器2:E:first-child */p:first-child { /* 样式 */} /* 选择器3:E:last-child */span:last-child { /* 样式 */} /* 选择器4:E:nth-of-type(n) */p:nth-of-type(2) { /* 样式 */} /* 选择器5:E:first-of-type */h1:first-of-type { /* 样式 */} /* 选择器6:E:last-of-type */ul:last-of-type { /* 样式 */} /* 选择器7:E:only-child */div:only-child { /* 样式 */} /* 选择器8:E:only-of-type */img:only-of-type { /* 样式 */}
结构选择器可以通过选择元素的位置和数量来选择元素。他们提供了更精细的选择器以及更准确的选择能力。 当您需要选择特定位置或数量的元素时,结构选择器将是您的选择。
最后值得一提的时,结构选择器与其他选择器不同的地方是它不会影响元素的其他选项。 也就是说,您可以与其他选择器一起使用,而不会影响其他选择器的结果。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: css3新增结构选择器(css3新增选择器有哪些)
本文地址: https://pptw.com/jishu/314844.html