| | |
auto resize back ground image to fit div width
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 101
Reputation:
Solved Threads: 9
•
•
•
•
can anyone suggest html/ css code for auto resizing background image to fit screen width
HTML and CSS Syntax (Toggle Plain Text)
.background { position:absolute; top:0; left:0; width:100%; z-index:-1; }
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.
Yes, I'm running Ubuntu. Of course.
•
•
Join Date: Jul 2008
Posts: 101
Reputation:
Solved Threads: 9
•
•
•
•
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....

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.
Yes, I'm running Ubuntu. Of course.
![]() |
Similar Threads
- Frame auto resize (HTML and CSS)
- Width Auto Resize to fit Screen (HTML and CSS)
- Making a table column auto-resize (HTML and CSS)
- code of image genration (PHP)
- Div width and list margin problem (HTML and CSS)
- Firefox Compatibility help with script (JavaScript / DHTML / AJAX)
- MDI Parent Form Layout Problem (VB.NET)
- MySpace Related : Trying to mount BG image on DIV, won't work, tried a few dif things (JavaScript / DHTML / AJAX)
- simple paint similar to MS Paint.. I have qustions! (VB.NET)
Other Threads in the HTML and CSS Forum
- Previous Thread: Frameset syntax...
- Next Thread: Frames
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7





