To ensure that the children of a container flow horizontally, you should apply display: inline-block
to them and also use white-space: nowrap
. Here is an example of the necessary CSS:
#Container {
width: 400px;
border: 1px solid black;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
}
.inside {
width: 100px;
height: 300px;
border: 1px solid black;
display: inline-block;
}
Additionally, here is the corresponding HTML structure:
<div id="Container">
<div class="inside"></div>
<div class="inside"></div>
<div class="inside"></div>
<div class="inside"></div>
<div class="inside"></div>
<div class="inside"></div>
</div>
For a visual representation and testing of the solution, you can check out this fiddle: http://jsfiddle.net/sgaurav/vZLWQ/