I am trying to utilise flexbox to create a vertical aligned images with content above and below on the odd and even.
Not sure whats happening with the example below but its not working on stackoverflow.
https://codepen.io/anon/pen/jgmMRy
Box 2 Box 3
text here single line
small text
......... ......... ......... .........
. . . . . . . .
. X . . X . . X . . X .
. . . . . . . .
......... ......... ......... .........
Box 1 Box 3
text here more long
for this text here
box... something
like this
and this..
The text can vary but i cant seem to work out on why this is not working. I have tried a few methods but keep failing whereby the images need to be aligned vertically but the content keeps floating right at the top.
section {
display: flex;
flex-direction: column;
justify-content: center;
}
.item {
display: flex;
flex-direction: column;
position: relative;
flex-basis: 0;
flex-grow: 1;
max-width: 100%;
& > div {
flex: 0 1 auto;
align-self: auto;
}
&:nth-of-type(even) {
.copy {
order: 0;
}
}
&:nth-of-type(odd) {
.copy {
order: 1;
}
}
}
<section>
<div class="row">
<div class="item">
<div class="copy">
<h2>heading</h2>
<p>loremAnte ultricies tincidunt primis elit dapibus ipsum at rutrum euismod class, litora orci integer mi dictum et curabitur duis tortor, cum potenti ultrices platea est commodo ornare magna rhoncus.</p>
</div>
<div class="imageMain">
<img src="https://via.placeholder.com/222x222" />
</div>
</div>
<div class="item">
<div class="copy">
<h2>heading</h2>
<p>loremAnte ultricies tincidunt primis elit dapibus ipsum at rutrum euismod class, litora orci integer mi dictum et curabitur duis tortor, cum potenti ultrices platea est commodo ornare magna rhoncus.</p>
</div>
<div class="imageMain">
<img src="https://via.placeholder.com/222x222" />
</div>
</div>
<div class="item">
<div class="copy">
<h2>heading</h2>
<p>loremAnte ultricies tincidunt primis elit dapibus ipsum at rutrum euismod class, litora orci integer mi dictum et curabitur duis tortor, cum potenti ultrices platea est commodo ornare magna rhoncus.</p>
</div>
<div class="imageMain">
<img src="https://via.placeholder.com/222x222" />
</div>
</div>
</div>
</section>