I'm looking to create a viewer composed of an arbitrary number of horizontally-aligned divs where only 3 are visible at any given time.
<div id="viewport">
<div id="slides">
<div>Content 1</div> <!-- not visible -->
<div>Content 2</div> <!-- visible -->
<div>Content 3</div> <!-- visible -->
<div>Content 4</div> <!-- visible -->
<div>Content 5</div> <!-- not visible -->
<div>...</div> <!-- not visible -->
</div>
</div>
My approach is to have a parent div ("viewport") of fixed width/height and overflow: hidden then to slide its child div ("slides"), which has the actual contents in its child divs, to the left or the right.
In order for this to work, I need the child divs of "slides" to be all horizontally aligned with none of them wrapping below, which will happen by default. I'm successful in doing this when I know and specify the cumulative width of the children of the "slides" div in CSS, but I will be dynamically adding/removing them in JS. I would like to avoid having to constantly change the width of the "slides" div through JS and would rather just find out how to do it in CSS.
So in short, how do I prevent a series of divs from wrapping below if the total width is unknown?