Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flexbox column align self to bottom

Tags:

css

flexbox

Im trying to use Flexbox. http://css-tricks.com/almanac/properties/a/align-content/ this shows nice alignment options; but i would actually want a Top-top-bottom situation.

I want a div to stick to the bottom of the parent div using flexbox. With flex-direction: column and align-content: Space-between i can do this, but the middle div will align in the center, i want the middle one to be sticked to the top as well.

[top]

[middle]

-

-

-

[bottom]

align-self: flex-end will make it float right, not bottom.

complete flexbox docs: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

like image 764
Laurens Kling Avatar asked Jul 11 '14 12:07

Laurens Kling


People also ask

Does align content override align-self?

The align-self applies to all flex items, allows this default alignment to be overridden for individual flex items. The align-content property only applies to multi-line flex containers, and aligns the flex lines within the flex container when there is extra space in the cross-axis.


2 Answers

I'm a bit late to the party, but might be relevant for others trying to accomplish the same you should be able to do:

margin-top: auto 

on the element in question and it should go to the bottom. Should do the trick for firefox, chrome and safari.

like image 180
Torbjørn Angeltveit Avatar answered Sep 20 '22 17:09

Torbjørn Angeltveit


Basically, the answer is to give to the last of the middle elements a flex grow 1 code as follows:

.middle-last{   flex-grow: 1; // assuming none of the other have flex-grow set } 

Thanks, T04435.

like image 41
T04435 Avatar answered Sep 19 '22 17:09

T04435