Is it possible to generate random color with pure CSS and without using javascript? It's probably impossible but I'm still curious.
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
I found for you something here, but it uses PHP. I think it's impossible with plain CSS.
Using PHP
according to this site, http://blog.codepen.io/2013/08/26/random-function-in-sass/ its possible but not with pure css
This isn't really possible in pure CSS.
However, using a pre-processor like SASS (example) or LESS (example) can generate random colors for you because they are built using scripting languages.
One side note that may help readers in the future is the possibility for using CSS variables. We can declare a CSS variable by saying
and use it like so:
Now we can change it using JS:
Or you could use a completely different way of selecting a random color (like user input). This allows for possibilities like theming. One thing you have to consider is browser support because it's not great right now.
Not really. Dynamism can only be implemented with the support of scripting.
Not exactly random but with CSS:
Step 1 - Select queried backgrounds, order them in sequence and adjust the frequency
Step 2 - Launch the animation(length animationName repeatMode)
Easy to use, customize and works great. Similar technique can be used for sliders, spinners, etc.