• @Bye
    link
    English
    261 year ago

    I don’t do web dev, I write math software that makes very rich people richer. But I often hear of this centering and layout crap

    Why doesn’t html just have hcenter and vcenter tags or something? Why is centering so hard?

  • BlackEco
    link
    fedilink
    English
    101 year ago

    I wasn’t expecting this to work, and yet it does: https://css-tricks.com/the-peculiar-magic-of-flexbox-and-auto-margins/

    When Sam says, “that item will automatically extend its specified margin to occupy the extra space in the flex container,” the way my empty filing cabinet brain interprets that is like so:

    Setting the margin property on a flex child will push the child away from that direction. Set margin-left to auto, the child will push right. Set margin-top to auto and the child will push to the bottom.

    […]

    Why is this useful to know? Well, I think there are a few moments where justify-self or align-self might not get you exactly what you want in a layout where using auto margins gives you that extra flexibility to fine-tune things.

  • @sunbytes
    link
    101 year ago

    “We have justify-content and align-items at home”

  • @[email protected]
    link
    fedilink
    6
    edit-2
    1 year ago

    Back in the day we didn’t have flex and had to use dark arts to center divs. Young frontend devs these days have it easy. Heck, back in the day there is no frontend devs, just cgi-bin programmers. Get off my lawn!

  • @Bye
    link
    English
    41 year ago

    deleted by creator

    • BlackEco
      link
      fedilink
      English
      7
      edit-2
      1 year ago

      Why doesn’t html just have hcenter and vcenter tags or something?

      HTML is a markup language, its purpose is to structure documents, while CSS can be seen as an additional layer that allows you to style and alter the layout of HTML documents. Because of this philosophy, it wouldn’t make any sense to have such tags.

    • I Cast Fist
      link
      fedilink
      English
      3
      edit-2
      1 year ago

      It actually has <center> for centering things horizontally. Yes, it’s literally <center> content </center>. It’s been around since the early 90s, too. Dunno about a vertical center</center>