Creating a Foundation-style Block Grid in Bootstrap 3?

后端 未结 4 557
刺人心
刺人心 2021-02-06 09:20

In Zurb Foundation 3+, they have a CSS construct of a \"block grid\" which is an unordered list where you can specify the number of items in a row.

Here\'s their docs on

4条回答
  •  梦谈多话
    2021-02-06 10:06

    Here is a responsive version gremo's answer:

    .make-block-grid(@class, @columns: @grid-columns, @spacing: @grid-gutter-width) when (@columns > 0) {
      .block-grid-@{class}-@{columns} {
        .clearfix;
    
        padding: 0;
        margin: 0 (-@spacing / 2);
    
        & > li {
          display: block;
    
          float: left;
    
          width: 100% / @columns;
          padding: 0 (@spacing / 2) @spacing;
    
          list-style: none;
    
          &:nth-of-type(1n) {
            clear: none;
          }
          &:nth-of-type(@{columns}n+1) {
            clear: both;
          }
        }
      }
    
      .make-block-grid(@class, @columns - 1);
    }
    
    .make-block-grid(xs);
    
    @media (min-width: @screen-sm-min) {
      .make-block-grid(sm);
    }
    
    @media (min-width: @screen-md-min) {
      .make-block-grid(md);
    }
    
    @media (min-width: @screen-lg-min) {
      .make-block-grid(lg);
    }
    

提交回复
热议问题