562
viadukt
8y

Front-end developer's to-do list :
☑ Climb Everest
☑ Learn how to speak mandarin
☑ Become god
◻ Vertically center something in CSS

Comments
  • 44
    Use flex!
  • 12
    Flexbox to the top!
  • 7
    align-items: center

    Done.
  • 32
    Yeah yeah, in theory there are 200 ways to do this and actually we know them.
    But there's always this case where you try your ass off and nothing does the job.😄
  • 17
    In case you cant use flexbox, set a position relative, a top of 50% and a transform translateY(-50%).
  • 14
    Why learn mandarin when you can just eat it? </ShitJoke>
  • 6
    Or if you want to shit all over the page you use:

    #element {

    position: absolute;

    top:0;

    right:0;

    bottom:0;

    left:0;

    margin:auto;

    }
  • 4
    Fuck css in particular, son of a bitch
  • 2
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);

    this works 90% of the time
  • 5
    CSS is great. Write 5 lines, run it; didnt work. Rewire, run again; didn't work. Repeat 2 more times...
    "Yes! The text stays within my margins!"
  • 1
    Flex box will change your life! ;)
  • 0
    Put a TODO,now it's another person's problem😂
  • 0
    .el{
    display: table;
    }
    .el .em{
    display: table-cell;
    vertical-align: middle;
    }
  • 0
    @CoffeeAllDay so this must be one of your struggles 😜
  • 1
    learn programming should be added to the bottom of that list
  • 0
    Use SASS
    Done
  • 1
    Le me trying to center something :
    Margin-left:auto
    Margin-right:auto
    Text-align:center
    Please.center.please.please(text)
  • 1
    align-items: center;
    /* If flex isn't available: */
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    /* You're welcome. */
  • 0
    I wrote a blog post on this! https://blog.kabir.ml/posts/...
  • 1
    That's easy...
Add Comment