tags:

views:

39

answers:

2

How can I set all images in one line and display only the first 200px of them inside the div?
Without breaking the layout, or moving images to a next line.
online demo

<div id="thumbsContainer">
   <ul>
    <li><img src="http://img214.imageshack.us/img214/6030/small3.jpg" alt="" /></li>
    <li><img src="http://img263.imageshack.us/img263/5600/small1ga.jpg" alt="" /></li>
    <li><img src="http://img638.imageshack.us/img638/3521/small4j.jpg" alt="" /></li>
    <li><img src="http://img682.imageshack.us/img682/507/small5.jpg" alt="" /></li>
    <li><img src="
http://img96.imageshack.us/img96/6118/small2o.jpg" alt="" /></li>   
   </ul>
  </div>

#thumbsContainer
{
 width:200px;
 overflow:hidden;

}
ul
{
list-style:none;
}
li
{
float:left;
}
A: 

How can I set all images in one line

Apply display:inline to your lis.

and display only the first 200px of them inside the div?

Apply width:200px and overflow:hidden to your div.

RegDwight
nemiss
A: 

Your div width is to short - if you know you image sizes and quantities up front, just fix the div width to fit.

If you want a 200px div with horizontal scrolling, then add 'display:inline' to your list items, and 'overflow:auto' and 'white-space:nowrap' to the div.

If you don't know sizes and/or quantities up front, but you want the list to expand on a single line no matter what, then you may need to use a table.

Ray
I made the div short in order to scroll thr images inside it. So it must be short.
nemiss
Then my second suggestion should work for you. You could apply these styles to the div or to the ul, depending on how you want things to look in the final design.
Ray
If I set 'overflow:auto' it works but I get the horizontal scroll bar - i don't want it because i will scroll with javascript
nemiss
oh - I see - I think then you will need 'overflow:hidden' - that is the only way I know of to hide the scroll bar. And the table idea wouldn't work at all.
Ray