943,955 Members | Top Members by Rank

Ad:
Aug 8th, 2009
0

auto resize back ground image to fit div width

Expand Post »
can anyone suggest html/ css code for auto resizing background image to fit screen width
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
varundeveloper is offline Offline
7 posts
since Aug 2009
Aug 8th, 2009
0

Re: auto resize back ground image to fit div width

can anyone suggest html/ css code for auto resizing background image to fit screen width
Define it as a normal image, and set this style:
HTML and CSS Syntax (Toggle Plain Text)
  1. .background
  2. { position:absolute;
  3. top:0;
  4. left:0;
  5. width:100%;
  6. z-index:-1;
  7. }

Then use:
<img class='background' src='sourcefile'>

Oh, in the subject line you write div width and in the body you write screen width. The above is for screen width but I'm sure you can adjust to also fit it in a div, although the div width may be decided by the image width.
Reputation Points: 16
Solved Threads: 9
Junior Poster
ingeva is offline Offline
106 posts
since Jul 2008
Aug 8th, 2009
0

Re: auto resize back ground image to fit div width

thanks for that.....
But still i need to fit the image within my pre-set div width....
and i want to do it using only css/html....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
varundeveloper is offline Offline
7 posts
since Aug 2009
Aug 9th, 2009
0

Re: auto resize back ground image to fit div width

thanks for that.....
But still i need to fit the image within my pre-set div width....
and i want to do it using only css/html....
width=100%; should do the trick, but you may have to experiment with the positioning. I'm not 100% sure about it and don't have the inclination to do all the work for you!

You should be able to do it with only html/css as long as the parameters are right.

Take a look at this, which is a suggestion for the top banner of a site I've started to work on: http://intertrafico.com/eldjarn

Vary the width of the window and see the text size change.

You'll see that the banner fills much more than the screen; it's a div with 1600% screen width and the banner consists of pictures that are shown in a random order. If you need to you can check the source and download the css file.
Reputation Points: 16
Solved Threads: 9
Junior Poster
ingeva is offline Offline
106 posts
since Jul 2008
Aug 9th, 2009
0

Re: auto resize back ground image to fit div width

yup....thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
varundeveloper is offline Offline
7 posts
since Aug 2009
Jan 7th, 2010
0
Re: auto resize back ground image to fit div width
can anyone suggest html/ css code for auto resizing background image to fit screen width
I came across this post while looking to solve the same problem. Have you finally found the solution? I'd be glad you could share it if so.

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ls233 is offline Offline
1 posts
since Jan 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: ants
Next Thread in HTML and CSS Forum Timeline: IP-Dependent Pages





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC