hey altcss1337,
In your example classes are being added and removed to the element using JavaScript.
That’s definitely the best way to do this while making sure it’s cross browser compatible.
If you want to use css instead, you could use keyframe animations and set the transitions to ‘step-end’ to make the transitions choppy.
It’s not truly random but when animated correctly, it will feel random. You would need to use JS to make it truly random.
I wrote you a pure css/html demo for this.
Try commenting out code and seeing what happens with it, specifically try deleting ‘step-end’.
https://codepen.io/philipbell/pen/pPKXye