How can I horizontally align my divs?

前端 未结 9 890
野的像风
野的像风 2020-11-28 03:47

For some reason my divs won\'t center horizontally in a containing div:

9条回答
  •  悲哀的现实
    2020-11-28 04:29

    Alignments in CSS had been a nightmare. Luckily, a new standard is introduced by W3C in 2009: Flexible Box. There is a good tutorial about it here. Personally I find it much more logical and easier to understand than other methods.

    .row {
      width: 100%;
      display: flex;
      flex-direction: row;
      justify-content: center;
    }
    .block {
      width: 100px;
    }
    Lorem
    Ipsum
    Dolor

提交回复
热议问题