I have this code which randomly shows a background image. I sized up the images and lower the bytes to lower the loading speed. However, I want the image to resize with whatever the screen size is.
<script type="text/javascript">
var randnum = Math.random();
var inum = 3;
var rand1 = Math.round(randnum * (inum - 1)) + 1;
images = new Array();
images[1] = "bgImages/Blue_Venetian_Glass.jpg";
images[2] = "bgImages/Etched Glass.jpg";
images[3] = "bgImages/glass.jpg";
images[4] = "bgImages/Raindrops_on_Glass.jpg";
var image = images[rand1];
document.body.style.background = 'url("' + image + '") no-repeat center center fixed';
</script>
My question is “what do I need to make the image stretch”
best way to achieve that effect would be to use a div with the image inside absolute positioned it that you can style.
HTML to add before
</body>:CSS:
Javascript: