css选择器

62 阅读1分钟
css的高级选择器 /* p:first-of-type选择属性其父元素的首个<p>元素 */ /* p:first-of-type{ background-color: pink; } */ /* p:last-of-type选择属性其父元素的最后<p>元素*/ /* p:last-of-type{ background-color: purple; } */ /* p:only-of-type 选择属于其父元素唯一的 <p> 元素 */ /* p:only-of-type{ background-color: red; } */ /* p:first-child选择属性其父元素第一个子元素的每个<p>元素 */ /* p:first-child{ background-color: royalblue; } */ /* p:last-child选择属性其父元素最后一个子元素的每个<p>元素 */ /* p:last-child{ background-color: salmon; } */ /* p:nth-child(n)选择属性其父元素的第n个子元素的每个<p>元素 */ /* p:nth-child(2){ background-color: skyblue; } */ /* p:before在每个<p>元素的内容之前插入内容 */ /* 伪元素:不是真正的元素,但是又具有元素的特征的元素 */ /* p:before{ content: '123'; } */ /* p:after在每个<p>元素的内容之后插入内容 */ /* p:after{ content: '456'; } */ </style>

1111111111111111

2222222222222222

3333333333333333

4444444444444444

5555555555555555

6666666666666666