animate css gradient array

andykais

I have a parent div the width of the screen with a set height. I want to animate smaller boxes of equal length inside it. I want to 'slide' the color of the smaller boxes with single a gradient for the parent div. This is one way I have implemented it with every box being a div with variable width:

tele

It has issues with mobile display so I need a new solution. I know that animating gradients with background position is possible, but what about animating portions of a gradient at a time.

The final version of this would include about 100 smaller boxes inside this div.I am looking for advice so if this makes more sense to just do in a canvas please let me know.

Ana

You could do it with each box being an individual gradient and then animate that gradient's background-size. However, I wouldn't recommend doing this. Animating 100 gradients is bound to be pretty bad for performance. As is animating the width of 100 elements (animating a scale() transform for each div would be better in that case).

If canvas is an option, then yes, use canvas, it's a much better choice in this case, both from a maintainability and from a performance point of view.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related