tags:

views:

42

answers:

3

Hello, I was wondering if there was a way to make a div containing images have an overflow that scrolls horizontially, as depicted in the projected diagram below:

alt text

as always, any help is greatly appreciated

+3  A: 

Something like this should work:

#imageContainer { 
  height: 200px;
  overflow: auto; 
  white-space: nowrap; 
}

Make sure the images aren't higher than the height parameter.

Eikern
nope, didnt work...
MRAISKY
What does your code look like?`<div id="#imageContainer"><img src="x.jpg"><img src="y.jpg"><img src="z.jpg"></div>`?
Eikern
A: 

Try just

overflow-x: auto;
cinqoTimo
+1  A: 

You need to know the width and amount of images inside the div to prevent it from wrapping:

<div id="outer">
    <div id="inner" style="width: 3200px;">
        <img src="1.jpg" />
        <img src="2.jpg" />
        <img src="3.jpg" />
        <img src="4.jpg" />
    </div>
</div>

And in CSS:

#outer {
    overflow: hidden;
    width: 800px;
    height: 600px;
}

#inner {
    height: 600px;
}

This example assumes your images are 800x600px, adjust as necessary.

Tatu Ulmanen
Is there any way that the width of the inner div can be automatic?
MRAISKY
No, but you can use Javascript to calculate it for you.
Tatu Ulmanen