Vertically align horizontal inline-block elements

前端 未结 3 878
囚心锁ツ
囚心锁ツ 2020-12-11 17:43

I\'ve got a checkbox group. Which are centrally aligned with checkboxes on top and text below. Here is what I mean :

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 17:59

    You can take a look here, I've made it from scratch...

    So what I did here is, I've used display: table; for the container element and am using display: table-cell; for the child div and as the child div are now table cells, I used vertical-align: top; so that the elements align to the top in those cells

    section {
      display: table;
      width: 100%;
    }
    
    section > div {
      vertical-align: top;
      display: table-cell;
      width: 33%;
      text-align: center;
    }

    Additional Info




提交回复
热议问题