css - 使用 :first line selector? 的边框半径

标签 css css-selectors

我的 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-radiuspadding :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 and font-family.

The color property, all background-related properties: background-color, background-image, background-position, background-repeat, background-size, and background-attachment, word-spacing, letter-spacing, text-decoration, text-transform, and line-height.

关于css - 使用 :first line selector? 的边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16892863/

相关文章:

javascript - 有没有办法自动向下滚动并加载任何使用无限滚动的网站的更多内容?

css - 显示选定的选项颜色 - AngularJS

html - 每种输入类型的通配符选择器

css - 选择具有不同类型 child 的最后一个 child

javascript - jQuery/Javascript 相当于 CSS 计数器?

CSS :focus border transition won't work when a border-bottom is already set

CSS 属性选择器与兄弟选择器混合

css - 在 css 中使用 not() 伪类的替代方法

html - 为什么没有显示 CSS 文件?

html - 编号类/id 的 CSS 选择器