I am faced with a design challenge involving two divs. The first div is floated left, while the second div is floated right. In order to achieve a responsive layout, I need the first div to go under the second div when the viewport changes. Both divs contain dynamic content and have variable heights.
I am seeking a solution using only CSS, without relying on javascript. While I know how to place the second div under the first one, I am struggling to reverse the order.
If anyone has experience or insight on how to accomplish this task, please share your knowledge!
HTML:
<div id="div1 sidebar" style="float: left;">
//dynamic content
</div>
<div id="div2 content" style="float: right;">
//dynamic content
</div>
It's important to note that the HTML is auto-generated, with div1 appearing before div2 in the markup. Changing the order of the divs (placing div2 above div1) is not recommended due to the widespread use of this layout structure across many pages.