Reputation: 279
I just building website everything working well but when I am trying to apply :before or :after pseudo-elements on some element so the small bubble should be behind the big one and it somehow not working and don't know why.
.bubble {
position: relative;
display: table-cell;
vertical-align: middle;
width: 135px;
height: 135px;
background-color: #666;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
-o-border-radius: 75px;
-ms-border-radius: 75px;
border-radius: 75px;
-moz-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
-webkit-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
z-index: 10;
}
.bubble.black:before {
top: 0;
left: 0;
content: "";
position: absolute;
width: 80px;
height: 80px;
background-color: #000;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
-o-border-radius: 75px;
-ms-border-radius: 75px;
border-radius: 75px;
-moz-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
-webkit-box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
z-index: 1;
}
<div class="bubble black"></div>
Upvotes: 1
Views: 139
Reputation: 122145
You can remove z-index
from parent and use z-index: -1
on pseudo element
.bubble {
position: relative;
width: 135px;
height: 135px;
background-color: #666;
border-radius: 75px;
box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
}
.bubble.black:before {
top: 0;
left: 0;
content: "";
position: absolute;
width: 80px;
height: 80px;
background-color: #000;
border-radius: 75px;
box-shadow: 0 0 50px 0 rgba(236, 3, 91, 0.20);
z-index: -1;
}
<div class="bubble black"></div>
Upvotes: 3