I am experimenting with css filters.
And I would like use the blur and grayscale at the same time, but I can\'t seem to use both simultaneously on the same image?
I'm trying to create utility classes in vanilla CSS and this would be helpful but it looks like it can not be done this way.
.brightness-20 {
filter:brightness(20%);
}
.image-grayscale-100 {
filter: grayscale(100%);
}
I'm not sure why they didn't just create a more specific property like:
filter-brightness: 20%; filter-grayscale: 100%
After some more work I came up with this solution:
/*Initalize Variables No Adjustments*/
:root {
--blur:0px;
--contrast:100%;
--brightness:100%;
--contrast:100%;
--dropshadow:0px 0px 0px black;
--grayscale:0%;
--hue-rotate:0deg;
--invert:0%;
--opacity:100%;
--saturate:100%;
--sepia:0%;
}
/*Apply Defult Variables To Image*/
.filter {
filter: blur(var(--blur)) contrast(var(--contrast)) brightness(var(--brightness)) contrast(var(--contrast)) drop-shadow(var(--dropshadow)) grayscale(var(--grayscale)) hue-rotate(var(--hue-rotate)) invert(var(--invert)) opacity(var(--opacity)) saturate(var(--saturate)) sepia(var(--sepia));
}
/*Override Defults*/
.brightness-20 {
--brightness:20%;
}
.image-grayscale-100 {
--grayscale: 100%;
}