I have a 2-column grid as follows: some text, followed by an image related to that text. On the other row the order is flipped:
| Text 1 | Image for Text 1 |
| Image for Text 2 | Text 2 |
| Text 3 | Image for Text 3 |
I created a standard grid to achieve it (jsfiddle: https://jsfiddle.net/6yxLpqmr/), extract from source:
<div class="pure-g">
<article class="pure-u-1 pure-u-md-1-2">Text 1</article>
<article class="pure-u-1 pure-u-md-1-2">Image for Text 1</article>
<article class="pure-u-1 pure-u-md-1-2">Image for Text 2</article>
<article class="pure-u-1 pure-u-md-1-2">Text 2</article>
<article class="pure-u-1 pure-u-md-1-2">Text 3</article>
<article class="pure-u-1 pure-u-md-1-2">Image for Text 3</article>
<!-- many more alternating articles like this -->
</div>
However, once the grid is collapsed on a narrow screen, it results in:
Text 1
Image for Text 1
Image for Text 2
Text 2
Text 3
Image for Text 3
<...>
Which is un-intuitive.
Q1: How can I change the result to:
Image for Text 1
Text 1
Image for Text 2
Text 2
Image for Text 3
Text 3
Q2: is it possible to write CSS in a way that creates the alternation by itself (without generating the CSS of course), while semantically keeping the HTML "in order" (image/text/image/text/...)?
It is better to create child box and use flex-direction: column-reverse. Check out the jsFiddle here.