I have a horizontally centered Flex item column, sorted from 1 to 5, aligned from the top of the container, like this:
body, html { height: 100%; position: relative; margin: 0; padding: 0; } .container { display: inline-flex; flex-wrap: wrap; flex-direction: column; align-items: flex-end; align-content: center; width: 100%; height: 100%; background: pink; } .item { margin: 1px; width: 30px; height: 30px; background: green; }
<div class=container><div class=item>1</div><div class=item>2</div><div class=item>3</div><div class=item>4</div><div class=item>5</div></div>
I want it to be aligned with the bottom of the container. I managed to do this using flex-direction: column-reverse;
like in the next snippet:
body, html { height: 100%; position: relative; margin: 0; padding: 0; } .container { display: inline-flex; flex-wrap: wrap; flex-direction: column-reverse; align-items: flex-end; align-content: center; width: 100%; height: 100%; background: pink; } .item { margin: 1px; width: 30px; height: 30px; background: green; }
<div class=container><div class=item>1</div><div class=item>2</div><div class=item>3</div><div class=item>4</div><div class=item>5</div></div>
But, as you can see, these projects are malfunctioning! Is there a way to have a Flex column at the bottom without reversing the order of items using CSS? I've tried every Flex property I know of so far with no success.
You need to use the
justify-content
attribute to align the content along the main axis (in your case vertical alignment). You are usingalign-items
which defines how items should be aligned along the cross axis.You can use
justify-content: end;