Is there a way to programmatically flip the background of an element using CSS or LESS? In particular, I would like to invert the background gradient of the button. I do not want the contents of the button to be flipped - only the background.
For example, this:
.button {background-image:linear-gradient(top, #000, #fff);}
should become:
.button:active {background-image:linear-gradient(top, #fff, #000);}
----------- EDIT: Add more details. -----------
Take this LESS code:
.button {
background-image:linear-gradient(top, red, green);
&.primary {background-image:linear-gradient(top, blue, yellow);}
&.secondary {background-image:linear-gradient(top, brown, grey);}
&:active {background-image:linear-gradient(top, ..., ...);}
}
Is there a way to change the direction of the gradient without having to separately define the ": active" state for the classes .button, .primary, and.. Secondary?
source
share