Is it possible to specify a <hue-interpolation-method> for anything other than gradients; specifically: transitions or animations?
.box {
width: 300px;
height: 50px;
}
.box.gradient {
background: linear-gradient(90deg in hsl longer hue, red, blue);
}
.box.transition {
background: red;
transition: 1s all;
}
.box.transition:hover {
background: blue;
}
.box.animation {
animation-name: color;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@keyframes color {
0% {
background: red;
}
100% {
background: blue;
}
}
Linear-gradient using hue interpolation:
<div class="box gradient"></div>
<br><br>
Transition (hover) -- how do I get it to use the hue interpolation?
<div class="box transition"></div>
<br><br>
Animation -- how do I get it to use the hue interpolation?
<div class="box animation"></div>
There is an active discussion to add a
transition-interpolationproperty that should cover it, but it's not yet ready.One other property that does use the
<hue-interpolation-method>is thecolor-mix()function, which actually has even better browser support than in gradients.However to animate this is not that easy.
One way is to define
@propertyvariables that we'll use as the percentage parameters ofcolor-mixand animate the custom variables instead.For browsers that don't support the
@propertyrule and thus animating custom variables (basically Gecko based browsers), you can create an animation with a lot of keyframes: