In my grid, each row contains text in one column and an image in the other. The order of these columns is determined by the user in a CMS and can vary for each row.
https://i.sstatic.net/MwR5O.png
On mobile devices, I always want the image to appear above the text. How can I adjust the grid layout using a media query to achieve this?
I have a fiddle here demonstrating the desktop layout, but I am unsure how to implement the necessary changes for the image to be displayed on top in mobile view. I believe flexbox might offer a solution. Any guidance would be appreciated!
https://jsfiddle.net/3opref6L/
The length of the rendered code may vary as it is generated by the CMS. Here is an example:
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="block htmlblock">
<p style="text-align: left;">TEXTTEXTTEXTTEXTTEXTTEXTTEXT</p>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="block image-block">
<img src="https://dummyimage.com/600x400/000/fff">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="block image-block">
<img src="https://dummyimage.com/600x400/000/fff">
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="block htmlblock">
<p style="text-align: left;">TEXTTEXTTEXTTEXTTEXTTEXTTEXT</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="block htmlblock">
<p style="text-align: left;">TEXTTEXTTEXTTEXTTEXTTEXTTEXT</p>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="block image-block">
<img src="https://dummyimage.com/600x400/000/fff">
</div>
</div>
</div>
</div>