My layout looks like this:
<div id='container'>
<div id='cont1' style='width:150px'>Content 1</div>
<div id='cont2' style='width:150px'>Content 2</div>
<div id='cont3' style='width:150px'>Content 3</div>
<div id='cont4' style='width:150px'>Content 4</div>
<div id='cont5' style='width:150px'>Content 5</div>
</div>
I want the div container
to horizontally scroll. I need cont1
through cont5
to stay within container
. I am looking for a way to horizontally scroll these 5 divs and arrange them next to each other as shown in the code.
I have been struggling to achieve this solution. For instance, consider the following structure:
<div id='container'>
<div id='internalcontainer' style='width:750px'>
<div id='cont1' style='width:150px'>Content 1</div>
<div id='cont2' style='width:150px'>Content 2</div>
<div id='cont3' style='width:150px'>Content 3</div>
<div id='cont4' style='width:150px'>Content 4</div>
<div id='cont5' style='width:150px'>Content 5</div>
</div>
</div>
I found it challenging to implement horizontal scrolling by placing the divs next to each other (content divs). I attempted to place them within a fixed width container inside the div responsible for the horizontal scroll. Even with this setup, styling was difficult. My questions are:
- Is it possible to achieve horizontal scrolling with the first structure?
- Is it viable to achieve horizontal scrolling with the second structure?
I experimented extensively with CSS properties like overflow
, but did not make progress...
Thank you!