| | |
Multiple images in a div wthout wrapping?
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I have a div in which I am placing several images, and by default they wrap so that each one appears below the one before it and they flow vertically downward. What I am wanting to do is to have them NOT wrap, and instead flow horizontally rightward.
I've tried floating all images to the left, and turning off whitespace wrapping, but this doesn't seem to do anything:
The only solution I've come across that works is to give the div a specific width:
However, I don't reliably know how wide all the given images will be (or indeed how many images there will be). These will be large images (a photo gallery) and they should extend off the side of the page so that the user can then horizontally scroll through them all. Is there a reliable css way to do this?
I've tried floating all images to the left, and turning off whitespace wrapping, but this doesn't seem to do anything:
HTML and CSS Syntax (Toggle Plain Text)
<div style="float: left; white-space: nowrap"> <img src="alpha.png"> <img src="bravo.png"> </div>
The only solution I've come across that works is to give the div a specific width:
HTML and CSS Syntax (Toggle Plain Text)
<div style="6500px;"> <img src="alpha.png"> <img src="bravo.png"> </div>
However, I don't reliably know how wide all the given images will be (or indeed how many images there will be). These will be large images (a photo gallery) and they should extend off the side of the page so that the user can then horizontally scroll through them all. Is there a reliable css way to do this?
Last edited by evank; Jul 20th, 2008 at 12:21 am.
--
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
~Terry Pratchett
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
~Terry Pratchett
•
•
Join Date: Jun 2008
Posts: 55
Reputation:
Solved Threads: 3
What you are doing is floating the div, not the images inside the div. You should target the images.
That would be the general idea.
HTML and CSS Syntax (Toggle Plain Text)
.float img {float: left; margin: 0 10px;} <div class="float">img img img img</div>
That would be the general idea.
Rexibit Web Services - Website Design - SEO - North Georgia Website Design
Don't just build it - CSS it.
Don't just build it - CSS it.
Hello evank,
What you need, - is a container you already have, and images that will fill the line.
*[ you should consider closing your img tags properly depending on DTD specified.]
If you plan for images to be scrollable with the browser-built horizontal scrollbar. You can use the following CSS:
It will make your DIV image container display a horizontal scrollbar.
But in case you plan to scroll them with javascript, than
/inf.:
Images are inline elements. They're allowed to break in a new line, just like text content does, in case it doesn't fit in existing available width.
Regards
What you need, - is a container you already have, and images that will fill the line.
*[ you should consider closing your img tags properly depending on DTD specified.]
If you plan for images to be scrollable with the browser-built horizontal scrollbar. You can use the following CSS:
HTML and CSS Syntax (Toggle Plain Text)
#yourImageContainer{ width: /*your desired area width*/; height:/*images height, or at least 1px higher than your images */; overflow: auto; white-space: nowrap; }
But in case you plan to scroll them with javascript, than
overflow:hidden is the way to go./inf.:
Images are inline elements. They're allowed to break in a new line, just like text content does, in case it doesn't fit in existing available width.
Regards
![]() |
Other Threads in the HTML and CSS Forum
- Previous Thread: Placing images without overflowing
- Next Thread: CSS Help
| 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 perl pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 xml xsl





