LessCSS - IE gradient filter with variables and lighten
As far as I know you can't mix escaping (because that's what you need here) and colour functions (lighen). So you'll need to store the startColor value in another variable.
@grayColor :#dddddd;
@greenColor : #ff0000;
@start : lighten(@grayColor, 3%);
.css {
filter:~"progid:DXImageTransform.Microsoft.gradient(startColorstr='@{start}', endColorstr='@{greenColor}', GradientType=0)";
}
LESSCSS escaping filter
Try this:
filter: ~"url('data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale')";
Dynamically change color to lighter or darker by percentage CSS
All modern browsers have had 100% filter
support since January 2020. Even UC Browser for Android (instead of Chrome, on the $80 phones) supports it.
a {
/* a nice, modern blue for links */
color: #118bee;
}
a:active {
/* Darken on click by 15% (down to 85%) */
filter: brightness(0.85);
}
Additionally, you can control this dynamically with CSS variables, which have been supported by most browsers since October 2017 (excluding QQ):
:root {
--color: #118bee;
--hover-brightness: 1.2;
}
a {
color: var(--color);
}
a:active {
/* Darken on click */
filter: brightness(var(--hover-brightness));
}
Not my project, but one that's great to look at for a real-world example of how great modern CSS can be, check out: MVP.css
Original Answer
If you're using a stack which lets you use Sass or Less, you can use the lighten
function:
$linkcolour: #0000FF;
a {
color: $linkcolour;
}
a.lighter {
color: lighten($linkcolour, 50%);
}
There's also darken
which does the same, but in the opposite direction.
Related Topics
CSS: Not(), Selectors and Selecting Descendants
How to Create a Box with a Left Arrow and Border
Submit Input Doesn't Get The: Active State in Ie8 When I Click on The Button's Text
Bullet Point Background Color Attribute? CSS
CSS Change Border Color on Hover
Why Is Fixed Background Image on Chrome Not Working
Bootstrap 3.3.6 Warnings and Errors in Bootstrap.Min.CSS
Vertically Aligning Block Element to Image
How to Target Chrome Only, Not All Webkit Powered Browsers
Sprites Less CSS Variable Increment Issue
Add Cell Borders in an R Datatable
How to Put The Text of Footer in Center and The Links of Menu in Center and Next to Each Other