我的 HTML 中有以下内容:
<p class="caption">Lorem Ipsum is a dummy text.It is used to display text in web page.</p>
在我的 CSS 中:
.caption:first-line
{
background-color:green;
border-radius:4px;
padding:5px 10px;
}
只有 background-color
被应用到第一行,其余的样式被省略。谁能帮忙?
最佳答案
那是因为 border-radius
和 padding
不 :first-line
选择器支持的属性.
以下引用摘自 MDN documentation :
Only a small subset of all CSS properties can be used inside a declaration block of a CSS ruleset containing a selector using the
::first-line
pseudo-element:all font-related properties:
font
,font-style
,font-variant
,font-weight
,font-size
,line-height
andfont-family
.The
color
property, allbackground
-related properties:background-color
,background-image
,background-position
,background-repeat
,background-size
, andbackground-attachment
,word-spacing
,letter-spacing
,text-decoration
,text-transform
, andline-height
.
关于css - 使用 :first line selector? 的边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16892863/