我有一个CSS类,可以在标题后输出一条线。
这在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>
编辑
根据要求提供JSFiddle
.sidebar
后,功能正常。 - Weafs.pyz-index: -1
被其他元素覆盖。 - Leo