I'm looking to darken an element on hover without also darkening the text color. I would like the text to remain pure white on hover.
Example:
<a href="#" class="badge" style="background-color: #0072CE;"><span>Some Text</span></a>
CSS:
.badge {
display: inline-block;
padding: 0.35em 0.65em;
font-size: 0.75em;
font-weight: 700;
line-height: 1;
color: white;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
text-decoration: none;
}
.badge:hover {filter: brightness(0.8);}
.badge > span {color: white;}
I tried applying positioning and z-index but that didn't work either. Also, I need the style tag because the background colors are generated dynamically.
Any help on the above or a different solution altogether would be appreciated!
EDIT: My appologies, I should have been clear that I also don't have access to set the hover color in the styles.