如何正确设置此样式规则的格式?
到目前为止,我有:
#speech p:first-letter {
font-size: 4em;
float: left;
line-height: 0.8em;
margin-right: 0.3em;
padding-right: 0.2em;
padding-bottom: 0.2em;
border: solid black;
border-right-width: 0.02em;
border-bottom-width: 0.02em;
}
这会更改#speech 部分中我所有段落的首字母。 如何包含 first-of-type 伪类以确保只更改第一段的字母?
最佳答案
试试这个:
#speech p:first-of-type:first-letter {
font-size: 4em;
float: left;
line-height: 0.8em;
margin-right: 0.3em;
padding-right: 0.2em;
padding-bottom: 0.2em;
border: solid black;
border-right-width: 0.02em;
border-bottom-width: 0.02em;
}
请查看demo .
关于css - 如何在我的样式规则选择器中使用 first-of-type 伪类和首字母伪元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17311625/