user3480996 user3480996 - 6 months ago 19
HTML Question

How can i bring a before pseudo element in front of a Background but behind of an other background?

I use mutiple Background. I use a before Element in the back of an multibackground with Css3 code and a background-image.
and i have also an other Background called (apc-container)behind this Background.

My problem is that the before Element is also behind the #acp-container.
in the pseudo element before i use the z-index.
i try to use this also in the #acp-container but it does not work.

So how i bring the before pseudo Element in front of the #apc-container and in the back of the #subfilter a BG?

you can check it out with this code and you see the problem easy.



#streams-container,
#acp-container {
border-radius: 10px;
background-color: #f8f8f8;
min-height: 500px;
}
.subfilter {
margin-top: 160px;
}
.subfilter a {
margin-right: 130px;
margin-left: 130px;
width: 145px;
height: 145px;
display: inline-block;
position: relative;
line-height: 145px;
background-size: auto auto, auto auto;
background-color: #eaeaea;
background-image: url(images/Eye.png), -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eaeaea));
background-image: url(images/Eye.png), -webkit-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -moz-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -ms-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -o-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), linear-gradient(top, #f6f6f6, #eaeaea);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
}
.subfilter a.finiwatch {
background-position: 0px -172px, 0 0;
}
.subfilter a:active {
top: 1px;
}
.subfilter a::before {
content: '';
position: absolute;
z-index: -1;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
background-color: #eaeaea;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
opacity: 0.5;
}
.subfilter a:active::before {
top: -9px;
}
.subfilter a:hover::before {
opacity: 1;
}
.subfilter a.finiwatch:hover::before {
background-color: #B3F390;
}
.subfilter a:hover {
top: 0px, 1px;
}
.subfilter a.finiwatch:hover {
background-position: -160px -158px, 0 0;
}
.subfilter a:active {
background: url(images/Eye.png), -moz-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -webkit-gradient(linear, left top, left bottom, from(#eaeaea), to(#f6f6f6));
background-image: url(images/Eye.png), -webkit-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -moz-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -ms-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -o-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), linear-gradient(top, #eaeaea, #f6f6f6);
}
.subfilter a.finiwatch:active {
background-position: -318px -158px, 0 0;
}
.subfilter a.finiwatch:selected {
background-position: -318px -158px, 0 0;
}

<div id="streams-container">
<div class="subfilter">
<a class="finiwatch" href=""></a>
</div>




Answer

Found a way

give apc-container a relative position and a z-index of 1 and teh before element a z-index of -10.

#streams-container,
#acp-container {
  border-radius: 10px;
  background-color: #f8f8f8;
  min-height: 500px;
  position: relative;
  z-index: 1;
}

.subfilter a::before {
  content: '';
  position: absolute;
  z-index: -10;
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -8px;
  background-color: #eaeaea;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  opacity: 0.5;
}