Dynamically change color to lighter or darker by percentage CSS (Javascript)
You can do this with CSS filters in all modern browsers (see the caniuse compatibility table).
.button {
color: #ff0000;
}
/* note: 100% is baseline so 85% is slightly darker,
20% would be significantly darker */
.button:hover {
filter: brightness(85%);
}
<button class="button">Foo lorem ipsum</button>
Here's more reading from CSS Tricks about the various filters you can use: https://css-tricks.com/almanac/properties/f/filter/
If you're using a stack which lets you use SASS, you can use the lighten
function:
$linkcolour: #0000FF;
a {
color: $linkcolour;
}
a.lighter {
color: lighten($linkcolour, 50%);
}
There is "opacity" which will make the background shine through:
opacity: 0.5;
but I'm not sure this is what you mean. Define "reduce color": Make transparent? Or add white?