Hey there! I've been using before and after in my element and it's been working well, but now I'm facing a problem. When I try to set a background color for the section, the before and after elements disappear. I understand that this issue arises due to z-index: -1, and I know that child elements like before and after cannot be stacked above the parent element. So, what could be the solution here? I don't want to add any new elements just to solve this:
This is what I'm aiming for:
https://i.sstatic.net/yvYhF.jpg
section{
height:400px;
padding:50px 0;
background-color:#00fb8f;
}
.box-shadow-1{
height:200px;
background-color:#e8e8e8;
position:relative;
}
.box-shadow-1:before,
.box-shadow-1:after {
z-index: -1;
position: absolute;
content: "";
bottom: 25px;
left: 10px;
width: 50%;
top: 80%;
max-width: 300px;
background-color:#ff0000;
-moz-box-shadow: 0 20px 20px #777;
-webkit-box-shadow: 0 20px 20px #777;
box-shadow: 0 20px 20px #777;
-webkit-transform: rotate(-8deg);
-moz-transform: rotate(-8deg);
-o-transform: rotate(-8deg);
-ms-transform: rotate(-8deg);
transform: rotate(-8deg);
}
.box-shadow-1:after {
-webkit-transform: rotate(8deg);
-moz-transform: rotate(8deg);
-o-transform: rotate(8deg);
-ms-transform: rotate(8deg);
transform: rotate(8deg);
right: 10px;
left: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section>
<div class="container">
<div class="row">
<div class="col-lg-11 col-lg-offset-1">
<div class="box-shadow-1">
Hey World
</div>
</div>
</div>
</div>
</section>