Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4: Mixing auto margins with flexbox #21426

Merged
merged 8 commits into from
Dec 25, 2016
Merged

v4: Mixing auto margins with flexbox #21426

merged 8 commits into from
Dec 25, 2016

Conversation

mdo
Copy link
Member

@mdo mdo commented Dec 25, 2016

screen shot 2016-12-24 at 6 11 21 pm

Turns out auto margins and flexbox make an amazing team. I discovered this while working on #21425 and really wanted to put something together for it. Using margin-{direction}: auto on a flex item will automatically place it on the opposite end of the flex items (when mixed with justify-content or align-items, at least). This makes for some awesome layout opportunities that are perfect for grids, modal footers, cards, and more.

@mdo mdo added this to the v4.0.0-alpha.6 milestone Dec 25, 2016
@Starsam80
Copy link
Contributor

Correct me if i'm wrong, but margin-top: auto and margin-bottom: auto always evaluate to 0, so having classes for these seem pointless. If I am wrong, then you should add a .my-auto class (margin-top: auto; margin-bottom: auto;)

@mdo
Copy link
Member Author

mdo commented Dec 25, 2016

Hmm, doesn't seem to be the case with flexbox. Here's how the align-items and top/bottom utils looks in the docs example I've created.

screen shot 2016-12-24 at 6 36 47 pm

@Starsam80
Copy link
Contributor

Huh, never thought about it being in a flex container. Most of the sources I saw online were before flexbox, so that's where I must have got the idea that margin-{top,bottom}: auto didn't work.

For completeness, I think you should also add the .my-auto class I mentioned before and a .m-auto { margin: auto; } class

// Some special margin utils
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains trailing whitespace

@mdo mdo merged commit 103cae2 into v4-dev Dec 25, 2016
@mdo mdo deleted the more-mx-auto branch December 25, 2016 22:03
@mdo mdo mentioned this pull request Dec 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants