html - Firefox::after 伪元素不工作

标签 html css firefox

我有一个 CSS 类,它在标题后输出一行

enter image description here

这在 Safari 和 Chrome 中有效,但在 Firefox 中不显示该行。

我的代码:

.sidebar h2 {
    color: #f7f7f7;
    width: 100%;
    font-size: 24px;
    position: relative;
}

.sidebar h2 span {
    background-color: #40d1b0;
    padding-right: 2px;
}
.sidebar h2::after {
    content:"";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0.22em;
    border-top: 1px solid rgba(0,0,0,0.10);
    z-index: -1;
}

<h2><span>Show</span></h2>

容器div有一个类Sidebar

编辑

请求的 JSFiddle

http://jsfiddle.net/jerswell/Lxsmt96k/

最佳答案

问题出在z-index,将较低的z-index放到侧边栏类中,这样它就不会再被隐藏了。

这是一个新的 fiddle ,我只是简单地将 z-index: -2; 放到了 .sidebar 选择器中。

PS(吹毛求疵):在CSS3中after不是伪类而是伪元素,并且有一个新的表示法:: :after (但是旧的符号仍然有效)

关于html - Firefox::after 伪元素不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27741043/

相关文章:

html - 如何在 Prestashop 中向 HomeSlider 图像添加动画 (html+css) 文本

javascript - 尝试使用 javascript 从 api 获取数据

javascript - 使用JS将浏览器版本作为类添加到<html>或<body>

firefox - 如何验证我的 Firefox 扩展的首选项?

html - Firefox 14下的CSS3动画

html - 并排图像和文本 : how to vertically center the text

css - 如果可见性没有过渡,为什么要将过渡应用于不透明度?

php - 具有固定高度的 HTML 可变图像宽度

html - 奇怪的填充/边距显示在 firefox/chrome

jquery - Internet Explorer 阻止 Jquery 并破坏我的网站