Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design Load random CSS on page load Reply To: Load random CSS on page load

#247693
Beverleyh
Participant

If you just want to load a single stylesheet each time, you could name them all as sequential numbers and use PHP’s mt_rand() function to call a random value each time.

So if you had 5 stylesheets, you could name them 1.css, 2.css, 3.css, 4.css and 5.css

Then insert a style link in the webpage head in the usual way, but echo in the number too. Something like;

<link rel="stylesheet" href="/path/to/styles/<?php echo(mt_rand(1,5));?>.css" />

(Untested – on mobile)