Trying to get a random background between two images.
The PHP (Before Doctype in index.php):
<?php
$bg = array('back1.jpg', 'back2.jpg' ); // array of filenames
$i = rand(0, count($bg)-1); // generate random number size of the array
$selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>
CSS:
body {
height: 100%;
margin: 0;
color: #474747;
font: 13px/23px 'Exo 2', sans-serif;
min-width: 1186px;
background: url( ../img/<?php echo $selectedBg; ?>) no-repeat 50% 50%;
background-size: cover;
background-attachment: fixed;
}
The issue is that the background isn't set to either of the images!
Aucun commentaire:
Enregistrer un commentaire