I am creating a responsive landing page which features several rows.
Each row consists of 2 div elements side by side - one with an image the other with text.
If one row has the image to the left and the text to the right-hand-side of the row, the next row will have the image to the right and the text to the left instead.
The problem is, for narrower screens I want that the div with text always stacks on top of the div with the image.
How can I achieve this responsive behaviour?
Here is my codepen:
https://codepen.io/ryanvb92/pen/MWbprvY
.section {
background-image: linear-gradient(to bottom, #eee, #fff);
}
.content {
padding-top: 60px;
padding-bottom: 60px;
width: 90%;
margin: auto;
display: flex;
flex-wrap: wrap;
}
.content .words {
padding: 50px;
background-color: pink;
}
.content .illustration {
background-color: lightblue;
}
<div class="section">
<div class="content">
<div class="words">
<h1>Lorem Ipsum</h1>
<p>The pink div should always be stacked on top when the breakpoint is surpassed.</p>
</div>
<div class="illustration">a
<!-- <img src="https://www.robertsoncomm.com/wp-content/uploads/2020/04/people.jpg"> -->
</div>
</div>
</div>
<div class="section">
<div class="content">
<div class="illustration">
<img src="https://img.freepik.com/free-vector/group-people-illustration-set_52683-33806.jpg?size=626&ext=jpg">
</div>
<div class="words">
<h1>Lorem Ipsum</h1>
<p>The pink div should always be stacked on top when the breakpoint is surpassed.</p>
</div>
</div>
</div>