I'm just wondering, is it possible to have randomly generated properties using only CSS, or will some javascript be required.
The effect I want to achieve is to have the coloured divs randomly positioned on the page.
http://jsfiddle.net/pphheerroonn/F95Ju/2/embedded/result/
HTML:
<div class="box wsbg1"></div>
<div class="box wsbg2"></div>
<div class="box wsbg3"></div>
<div class="box wsbg4"></div>
CSS:
body {
height: 600px; background-color: #66ccff;}
.box {
height: 200px; width: 200px;
-webkit-transform: rotate(-5deg);
-moz-transform: rotate(-5deg);
-webkit-box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.3);
}
.wsbg1 {background-color: #ec0689;}
.wsbg2 {background-color: #ffde00;}
.wsbg3 {background-color: #09aeee;}
.wsbg4 {background-color: #5eb345;}
No, CSS is deterministic. Either create randomness with javascript, or serve up a randomly generated css file each time with PHP.
You could do that with CSS pre processors such as LESS or SASS, here is a relevant answer for the same:
Possible to create random numbers in SASS / Compass?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With