51
ctrlz
4y

Oke so this just happened...

Spent 30 minutes figuring out why the f**k a div was vertically centered within another one.

Apparently margin:auto within a display: flex not only centers horizontally but also vertically.

I remember the days when i spent hours vertically centering sh*t. What universe are we in?

Comments
  • 7
    Saved to favorites so I never have to cry about that problem again
  • 0
    Could someone provide an example? I'm not into web development but it seems really interesting
  • 2
    Oh I feel sorry for web devs, I think they are the most suffering devs on earth, I do have similar problems in mobile development but non that make me suffer like this one
  • 2
    https://jsfiddle.net/7fz4o16q/1/

    Looks like jsfiddle is not a brilliant mobile service. Anyway, idea is clear.
  • 0
    @ctrlz you made me blind with that red background lol
  • 1
    Hahaha oops @gitpush better now?
  • 0
    @ctrlz haha yes yes much better
  • 6
    @ctrlz lol "background:Peachpuff;"
  • 2
    @ctrlz I thought flex can only center szuff in one dimension, either horizontaly or verticaly and that's why there's grid (well at least it's comming).

    Ok grid has a lot of other cool stuff, like "reordering" content based on display size.
  • 0
    If this works it's a good find. I normally do

    Display: flex;
    Align-items: centre;
    Text-align: centre;
  • 1
    @Wack take a look at the jsfiddle. I dont make this shit up. 😄
  • 1
    @ctrlz I did, that's why I was so surprised.
Add Comment