CSS - Equal Height Columns?

前端 未结 11 1154
情歌与酒
情歌与酒 2020-11-21 06:08

In CSS, I can do something like this:

But I\'ve no idea how to change that to something like:


Is this possible with CSS?

11条回答
  •  我寻月下人不归
    2020-11-21 06:53

    Here is an example I just wrote in SASS with changeable column-gap and column amount (variables):

    CSS:

    .fauxer * {
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box; }
    
    .fauxer {
      overflow: hidden; }
    
    .fauxer > div {
      display: table;
      border-spacing: 20px;
      margin: -20px auto -20px -20px;
      width: -webkit-calc(100% + 40px);
      width: -moz-calc(100% + 40px);
      width: calc(100% + 40px); }
    
    .fauxer > div > div {
      display: table-row; }
    
    .fauxer > div > div > div {
      display: table-cell;
      width: 20%;
      padding: 20px;
      border: thin solid #000; }
    Lorem column 1
    Lorem ipsum column 2 dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
    Lorem column 3
    Lorem column 4
    Lorem column 5

    Note: I only found the time to test it in some new browsers. Please test it well before you will use it :)

    The editable example in SCSS you can get here: JSfiddle

提交回复
热议问题