I have a variety of buttons with different background images. My goal is to apply a grayscale filter to the backgrounds by default and remove the filter on hover, without affecting the color of the button text.
Currently, when I apply the grayscale filter, the text of the buttons also becomes grayed out. I need help figuring out how to only apply the grayscale filter to the button backgrounds, not the text itself.
Right now, I'm using a CSS class for the buttons:
.box {
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
position:relative;
color: red;
cursor:pointer;
text-align: center;
width: 160px;
height: 160px;
}
.box:hover {
-webkit-filter: grayscale(0%);
filter: grayscale(0%);
color: blue;
}
And in my HTML code, I'm adding the backgrounds for each button like this:
<button onclick="buttonFunction()" button class="button box" style="background: url(background1.jpg); background-size: 100%;" >Gray button text:( </button>
Does anyone have any ideas on how to achieve a grayscale filter on button backgrounds while keeping the button texts colored? Thanks!