There is a rectangle:
<div class="i">Hi world!</div> His styles are:
.i{ height: 100px; width: 300px; text-align: center; font-size: 16px; background-color: #eee; color: #fff; position: relative; z-index: 1; } And its overlay:
.i::before{ content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; opacity: 0.5; } It was expected that z-index: 1; override the overlay, and the text will be white, but in fact it does not.
Why, and how to cure?