Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS What is the correct/standard way of centering a container?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #271816
    boqsc
    Participant

    Here with the new layout systems like Grid and Flexboxes.
    What is the (modern) standard way of centering a container that is either flexbox or a grid.
    Should we use grid to center a grid container? Or there is more elegant ways to do this?

    #271817
    Paulie_D
    Member

    The same way you center any block level element

    margin: auto

    Doesn’t get any simpler than that. Anything else is overkill IMO.

    …or unless there is something you haven’t mentioned.

    #271835
    tomnoble92
    Participant

    Depends if it’s vertical or horizontal.

    Css Tricks has an article on this.

    https://css-tricks.com/centering-css-complete-guide/

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.