Firefox :: after pseudo element doesn't work

I have a CSS class that outputs a line after the title

enter image description here

This works in Safari and Chrome, but the line doesn't appear in Firefox.

My code:

.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>

      

The div container has a class Sidebar

EDIT

JSFiddle as requested

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

+3


source to share


2 answers


The problem is z-index

, set the bottom one z-index

to the sidebar class so that it doesn't hide anymore.

Here is a new fiddle , I just put z-index: -2;

in a selector .sidebar

.



PS (nitpicking): In CSS3 after

it is not a pseudo-class, but a pseudo-element, and there is a new notation for it: ::after

(however the old notation works)

+3


source


If we change the z-index of the .sidebar to a minus value, later it might have a layout issue. Other elements may overlap this element. We have to use:



.sidebar h2{position:relative;}
.sidebar h2 span{position:relative;z-index:2;}
.sidebar h2:after{z-index:1;}

      

0


source







All Articles