How can I horizontally align my divs?

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

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

9条回答
  •  無奈伤痛
    2020-11-28 04:22

    Using FlexBox:

    Lorem
    Ipsum
    Dolor
    .row { width: 100%; margin: 0 auto; display: flex; justify-content: center; /* for centering 3 blocks in the center */ /* justify-content: space-between; for space in between */ } .block { width: 100px; }

    The latest trend is to use Flex or CSS Grid instead of using Float. However, still some 1% browsers don't support Flex. But who really cares about old IE users anyway ;)

    Fiddle: Check Here

提交回复
热议问题