Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a gif fullscreen for a webpage background?

Tags:

html

css

gif

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?

like image 283
user3264048 Avatar asked Feb 05 '14 22:02

user3264048


People also ask

Can you use a GIF as a background image?

Yes, you can use an animated GIF as an animated background cross-browser in the CSS, if I understand your question right.

How do you display a GIF in HTML?

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.

How to make an animated GIF as a website background?

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.

Can the background image be full screen?

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'.

How to make full screen backgound in a web page?

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.

How do I put a background image on my website?

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%; }


2 Answers

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;
}
like image 131
Juan Avatar answered Sep 19 '22 09:09

Juan


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

like image 31
zsaat14 Avatar answered Sep 20 '22 09:09

zsaat14