:first-child(首个子对象) p:first-child {font-weight: bold;} li:first-child {text-transform:uppercase;}
p:nth-child(2)
在下面的例子中,选择器匹配所有
元素中的第一个 元素: p > i:first-child { font-weight:bold; }
在下面的例子中,选择器匹配所有作为元素的第一个子元素的
元素中的所有 元素: p:first-child i { color:blue; }
“first-line” 伪元素用于向文本的首行设置特殊样式。
在下面的例子中,浏览器会根据 “first-line” 伪元素中的样式对 p 元素的第一行文本进行格式化: p:first-line { color:#ff0000; font-variant:small-caps; }
:first-letter 伪元素 “first-letter” 伪元素用于向文本的首字母设置特殊样式: p:first-letter { color:#ff0000; font-size:xx-large; }
CSS2 - :before 伪元素 “:before” 伪元素可以在元素的内容前面插入新内容。 下面的例子在每个
规定属于其父元素的第二个子元素的每个 p 的背景色: p:nth-child(2) { background:#ff0000; }
transition: 0.5s all ease; -webkit-transition: 0.5s all ease; -moz-transition: 0.5s all ease; -o-transition: 0.5s all ease; -ms-transition: 0.5s all ease;
body a { transition: all 0.5s ease 0s; } 背景颜色渐变
li:last-child{background:none;}… prev next
