I've implemented some PHP and CSS code to select random background images for a landing page. When you first access the page there are loading problems, like the background image doesn't appear, or only part of the background image shows up (underneath the actual content). This happens across all platforms on devices.
When I hit refresh the images start to appear correctly, but before the first one or two refreshes they don't.
Thanks for your help. You can see the page here:
HTML:
<?php
$bg = array('bg-01.gif', 'bg-02.gif', 'bg-03.gif', 'bg-04.gif', 'bg-05.gif', 'bg-06.gif', 'bg-07.gif', 'bg-08.gif', 'bg-09.gif', 'bg-10.gif', 'bg-11.gif', 'bg-12.gif', ); // 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
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1100">
<title>Boris Kholodov · Real Estate Broker · Toronto, Canada</title>
<meta name="description" content="List your property with Boris Kholodov, the Number 1 real etsate broker in downtown and central Toronto by number of units sold in 2014.">
<link rel="stylesheet" type="text/css" href="design.css">
<!-- BACKGROUND IMAGES -->
<style type="text/css">
<!--
body{
background: url(backgrounds/<?php echo $selectedBg;?>) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
-->
</style>
<!-- BACKGROUND IMAGES -->