I'm trying to make a GIF fit my whole screen, but so far its just a small square that is on my screen while the rest is white. However, I want it to take up all the space.
Any ideas?
Yes, you can use an animated GIF as an animated background cross-browser in the CSS, if I understand your question right.
Animated images in HTML are an image on a web page that moves. It is in GIF format i.e. Graphics Interchange Format file. To add an animated image in HTML is quite easy. You need to use the <image> tag with the src attribute.
With the file uploaded to WebStarts go to File> Background > Image and apply the image with the "Fullscreen" radio button selected then click "Apply". Congratulations - That's how to make an animated GIF as your website background.
But the image can be full screen, if I put it as background image of 'body'. Because the default 'margin' of 'body' is not zero. After add this css, the background image can be full screen even I put it in 'div'.
Use this CSS to make full screen backgound in a web page. Make a div 100% wide and 100% high. Then set a background image. A quick search for keywords background generator shows this CSS3 produced background pattern that's dynamically created.
Background Image Method If you want it to be the background image of you page, you can use this CSS: body { background-image:url ('folder/image.gif'); background-size:100%; background-repeat: repeat-y; background-attachment: fixed; height:100%; width:100%; }
if it's background, use background-size: cover;
body{
background-image: url('http://i.stack.imgur.com/kx8MT.gif');
background-size: cover;
height: 100vh;
padding:0;
margin:0;
}
IMG Method
If you want the image to be a stand alone element, use this CSS:
#selector {
width:100%;
height:100%;
}
With this HTML:
<img src='folder/image.gif' id='selector'/>
Fiddle
Please note that the img tag would have to be inside the body tag ONLY. If it were inside anything else, it may not fill the entire screen based on the other elements properties. This method will also not work if the page is taller than the image. It will leave white space. This is where the background method comes in
Background Image Method
If you want it to be the background image of you page, you can use this CSS:
body {
background-image:url('folder/image.gif');
background-size:100%;
background-repeat: repeat-y;
background-attachment: fixed;
height:100%;
width:100%;
}
Fiddle
Or the shorthand version:
body {
background:url('folder/image.gif') repeat-y 100% 100% fixed;
height:100%;
width:100%;
}
Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With