-1

I am trying to get my background image to fit screen without stretching it. My image rotates every time my website is shown.

Any help would be greatly appreciated.

body {
height: 100%;
margin: 0; 
padding: 0;
}

Code for background image.

#page-background {
height: 100%;
left: 0;
position: fixed; 
top: 0;   
width: 100%;
}

Code for background image to rotate..

<div id="page-background">
<?php
//Add as many links you want
$mylink[1] = '<img src="http://www.zarias.com/wp-content/uploads/2015/12/61-cute-puppies.jpg" width="100%" height="100%">
<div id="download">
<a href="images/more.png" title="Download this image. Use of this image is restricted to wallpaper only"download>* Download This Image *</a>
</div>';
// this will count your links itself and select a random one
$id = rand(1,count($mylink));
// this will display the random link
echo $mylink[$id];
?>
</div>
Laurie Williams
  • 41
  • 1
  • 1
  • 4
  • 1
    Possible duplicate of [Stretch and scale a CSS image in the background - with CSS only](https://stackoverflow.com/questions/1150163/stretch-and-scale-a-css-image-in-the-background-with-css-only) – drudge Apr 14 '18 at 00:28
  • Your included PHP code is useless in this case and only gets in the way. Please remove the PHP part, leaving only the necessary HTML, so we don't have to edit it ourselves to help you. [mcve] – Rob Apr 14 '18 at 00:52

1 Answers1

0

Why don't try to use viewports? You can set the image size responsive to your browser. viewports

Alan Aranda
  • 202
  • 3
  • 14