I would like to align three DIVs side by side in their parent DIV, but if total width of the three DIVs exceeds the width of the parent, I would instead like each of the three DIVs to display one on top of the other. Each of the three DIVs have variable width content and it doesn't make sense to try to fix the width of those DIVs. I've been generally using display:inline-block
but that doesn't help when the parent width can fit two of three DIVs.
<div class="parent">
<div class="a">aaa</div>
<div class="b">bbb</div>
<div class="c">ccc</div>
</div>
If the parent DIV is wide enough, I'd like to see them as:
AAA BBB CCC
and if it is not wide enough, I'd like to see them as:
AAA
BBB
CCC
What I'm actually seeing as the parent gets more narrow (or children get wider) is:
AAA BBB
CCC
Is there any CSS only solution?
EDIT: I've been asked what I am trying accomplish specifically. Basically, I have a set of search results that spans multiple pages. The page navigation is set up as a First\page number\Last type setup, so it could look like: First 1 2 3 Last
or First 12 13 14 15 16 Last
depending on the number of results. I guess I could just always have it stack on smaller devices to prevent an awkward wrap, but I like it in-line better from a visual perspective when there is the room to do so.