In my code, I have an outer div with an inner div containing a list of images. The issue I am facing is that when the images are wider than the outer div, instead of scrolling horizontally as desired, they just move to the next line without expanding. In cases where there are multiple rows, the div scrolls vertically but not horizontally. I have tested this on various browsers including Firefox, Chrome, IE, and Safari.
Below is the CSS:
#grid-container { left:33px; position:relative; width:300px; }
#grid { width:310px; height:400px; overflow:auto; margin-bottom: 15px; }
#grid-container ul { width:305px; }
#grid-container li { float:left; list-style-type:none; padding:5px 15px 5px 15px; height:88px; text-align:center; }
.image-row { float:left; margin-left: 10px; }
.grid-image { height:50px; margin-left:-20px; }
And here is the HTML structure:
<div id="grid-container">
<div id="grid">
<div id="row1" class="image-row">
<ul>
<li>
<img id="img1" class="grid-image" src="images/img1.jpg">
</li>
<li>
<img id="img2" class="grid-image" src="images/img2.jpg">
</li>
<li>
<img id="img3" class="grid-image" src="images/img3.jpg">
</li>
<li>
<img id="img4" class="grid-image" src="images/img4.jpg">
</li>
</ul>
</div>
<div id="row2" class="image-row">
<ul>
<li>
<img id="img5" class="grid-image" src="images/img5.jpg">
</li>
<li>
<img id="img6" class="grid-image" src="images/img6.jpg">
</li>
</ul>
</div>
</div>
</div>
The problem arises with img4 displaying on the second row (alongside img5 and img6 on the third row) instead of the first row, causing the grid
div to scroll vertically only. Is there a way to force the div to expand? Removing the width from the grid div does introduce a horizontal scroll bar, but the image still remains on the second row.