Multiple images in a div wthout wrapping?

Reply

Join Date: Dec 2006
Posts: 14
Reputation: evank is an unknown quantity at this point 
Solved Threads: 0
evank's Avatar
evank evank is offline Offline
Newbie Poster

Multiple images in a div wthout wrapping?

 
0
  #1
Jul 20th, 2008
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:
HTML and CSS Syntax (Toggle Plain Text)
  1. <div style="float: left; white-space: nowrap">
  2. <img src="alpha.png">
  3. <img src="bravo.png">
  4. </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)
  1. <div style="6500px;">
  2. <img src="alpha.png">
  3. <img src="bravo.png">
  4. </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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 55
Reputation: rexibit is an unknown quantity at this point 
Solved Threads: 3
rexibit rexibit is offline Offline
Junior Poster in Training

Re: Multiple images in a div wthout wrapping?

 
1
  #2
Jul 20th, 2008
What you are doing is floating the div, not the images inside the div. You should target the images.

HTML and CSS Syntax (Toggle Plain Text)
  1. .float img {float: left; margin: 0 10px;}
  2.  
  3. <div class="float">img img img img</div>

That would be the general idea.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 14
Reputation: evank is an unknown quantity at this point 
Solved Threads: 0
evank's Avatar
evank evank is offline Offline
Newbie Poster

Re: Multiple images in a div wthout wrapping?

 
0
  #3
Jul 20th, 2008
Good point, don't know how I missed that. However, floating the images doesn't achieve the intended effect either, and actually just floats them outside the containing div while still wrapping them downward
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz

Re: Multiple images in a div wthout wrapping?

 
0
  #4
Jul 20th, 2008
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:
HTML and CSS Syntax (Toggle Plain Text)
  1. #yourImageContainer{
  2. width: /*your desired area width*/;
  3. height:/*images height, or at least 1px higher than your images */;
  4. overflow: auto;
  5. white-space: nowrap; }
It will make your DIV image container display a horizontal scrollbar.

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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC