We help IT Professionals succeed at work.
Get Started

Background image: Size to fit, bottom of page not screen

Ryan asked
Last Modified: 2012-05-05
I have an image that is 1200x500. I want it on the bottom of the page, not the screen (so on a long page you won't be able to see the image unless you scroll down).

I'd like it to stretch to fit the width of the screen, but maintain aspect ratio if possible. (I've read this can only be done using <img> not CSS.

Currently using the bg style, I have the image in the background, but its at the top of the screen. (so you see it at all times).

The body style, has the image initially at bottom of the screen, and when you scroll down, it stay up.

The image is not suitable for tiling.
/*In the CSS File*/
body {height:100% margin:5px 0; padding:0; font: 74% Arial, Sans-Serif; color:#000; line-height: 1.8em; background : #3a7de6;
/*I want it to be at the bottom of the page, not screen., would also be good if it could be zoomed (proportional stretch)to full width*/
.bg {background: #3c80eb;
float: bottom;
/*In the HTML File*/
<div class="bg"><img src="images/BckGrnd.jpg" width="100%" alt="" /></div>
<div class="content">

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE