css - 是否有第三个伪元素,比如 after 和 before

标签 css

我需要类似 .foo.bar 的第三个伪元素。

.foo.bar:before { content: "x "; }
.foo.bar:after { content: " x"; }

.foo.bar:before:before { content: "bad "; color: red; }
<div class="foo">apple</div>
<div class="foo bar">orange</div>
<div class="foo">chainsaw</div>
 

最佳答案

没有。 不可能(使用 CSS)添加到 ::before::aftercontent: 之前,或者换句话说 — 使 content:"x"; 成为 bad x 因为任何已定义的规则都会覆盖旧规则,并且没有第三个​​::before::after 伪元素。

关于css - 是否有第三个伪元素,比如 after 和 before,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39095572/

相关文章:

html - 相对于输入长度的字体大小

html - 我需要帮助创建 4 列,并在其下方一行两列

javascript - 折叠 div 时 float 背景

html - div 内的 CSS div 对齐,宽度为 100%

javascript - 为什么:hover in this CSS code not work?

html - 如何缩小包含表格的div的大小

html - 页脚中的居中和间距图标

javascript - 我的 Jquery 单击按钮不起作用

javascript - 如何将工具栏中的按钮设置为禁用

css - 如何预加载 css :hover background images