Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background content image needs to stick to bottom

I'm trying to push my background content image and make it stick to bottom of my page. The image is NOT a footer since the image will be behind some of the content. But the image shouldn't get cut off at the top when there is little content and and should stick to the bottom when there is loads of content!

Nothing working quite yet. Anyone got any tips for me?

Here are two examples. One with content fitting the window and the other with a lot more content.

Here are two links;

http://www.andrewa.org/testing/mosaik-test/content-imagebottom-test.html

http://www.andrewa.org/testing/mosaik-test/content-imagebottom-test2.html

Thank you in advance folks!

like image 882
Andrew Avatar asked May 18 '11 20:05

Andrew


People also ask

How do I put a background picture on the bottom?

background-position takes two arguments, an x-value and an y-value so to position it at the bottom, you would use: background-position: center bottom; .

How do I make my background stick to the bottom of a div?

Add min-height: 100% instead of the height: 950px , that will give your div the height necessary. Second, use position:fixed to lock the background image at the same place (for scrolling).

How do you keep the position of a picture fixed?

you can try position:fixed css style. That will fix your picture regardless you maximize or minimize the screen. Hope it will help. And by this if user will resize window, he will not be able to see image..

What is the correct way of inserting the background image?

The most common & simple way to add background image is using the background image attribute inside the <body> tag.


1 Answers

I would put the image as a background to the body using background-attachment: fixed; and add:

html, body {
  height: 100%;
}

So the total would be:

html, body {
  height: 100%;
}
body {
  background-image: url("images/bg_content.gif");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
like image 50
jeroen Avatar answered Sep 21 '22 17:09

jeroen