I have a scenario where I need to "activate" a selection of text and "bring it forward", by setting opacity to 1 from a default of 0.5. I can't bring an element forward though by setting a higher z-index. I've tried playing with position: relative
but no success. See the snippet, by setting a higher z-index to .c1
, .c2
is still visible. Any ideas?
mark {
background-color: transparent;
padding: 0;
font-weight: normal;
}
.c1 {
background: rgb(255,236,132);
z-index: 1;
}
.c2 {
background: rgb(254,183,183, 0.5);
}
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <mark class="c1">Ut enim ad minim veniam, quis nostrud exercitation ullamco <mark class="c2">laboris nisi ut aliquip ex ea commodo consequat. Duis</mark> aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat</mark> cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
By setting a z-index to the first element, it still remains in the back of the second element.