I'm trying to create a carousel from ul object where the li elements are blocks and ul is the carousel container. I've tried two approaches but neather seems to work, the overflow property is not functioning as I want it to.
Approach 1:
<ul style="overflow:hidden; width:200px; height:120px; display:block;">
<li style="float:left; display:block; width:100px; height:100px; margin:0 20px 0 0; background-color:black;"> </li>
<li style="float:left; display:block; width:100px; height:100px; margin:0 20px 0 0; background-color:black;"> </li>
<li style="float:left; display:block; width:100px; height:100px; margin:0 20px 0 0; background-color:black;"> </li>
</ul>
The problem with this approach is that elements don't stack horizontally when they overflow (which is what I want/expected). I suspect this is due to the display:block in the li elements, but they need to have fixed width/height, is there a way around this ?
Approach 2:
.ui-carousel
{
display:block;
overflow: hidden;
list-style: none;
}
.ui-carousel-element
{
margin:0;
padding:0;
display:block;
border:2px solid black;
float:left;
}
<ul style="width: 200px; height: 120px; padding-top: 20px;" id="pages" class="ui-widget ui-carousel">
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 0px;" class="ui-carousel-element ui-widget-content"> </li>
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 100px;" class="ui-carousel-element ui-widget-content"> </li>
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 200px;" class="ui-carousel-element ui-widget-content"> </li>
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 300px;" class="ui-carousel-element ui-widget-content"> </li>
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 400px;" class="ui-carousel-element ui-widget-content"> </li>
<li style="width: 80px; height: 80px; position: absolute; top: 20px; left: 500px;" class="ui-carousel-element ui-widget-content"> </li>
</ul>
I use javascript to distribute the li elements and set their positions to absolute but then the overflow:hidden property is 'ignored' because li elements still show up outside of the ul container bounds.
So the question is how to get ul to horizontally stack fixed size li blocks and hide the ones that overflow ?