I have a series of images that are shown in gray scale when the element has the class, disabled
but this filter is also being applied to the child elements, so the entire block appears in gray.
.item {
background-size: cover;
width: 400px;
height: 200px;
text-align: center;
padding-top: 20px;
}
.item.disabled {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
}
.item .status {
background-color: green;
bottom: 30px;
border-radius: 6px;
padding: 2px 5px;
color: white;
font-weight: bold;
}
.item.disabled .status {
background-color: red;
}
<div class="item" style="background-image: url(http://lorempixel.com/400/200/sports)">
<span class="status">ready</span>
</div>
<div class="item disabled" style="background-image: url(http://lorempixel.com/400/200/sports)">
<span class="status">not ready</span>
</div>
How to make the text that says "not ready" come out in red and not in gray?
As I understand it, the css filter property is not inheritable and its initial value is none
so that it should only apply to the element it is on.
This had happened to me a long time ago, but with the filter: blur, the solution is to play with the positions of the boxes.