How can I create a “gallery” with singularitygs?

落花浮王杯 提交于 2019-12-06 16:34:16

Float span

Here's a solution:

.footer__blocks {
  @include grid-span(1, 2);

  $cols: 3;

  @include layout($cols, $gutter: 0) {
    .footer__block {
      @include float-span(1);
      &:nth-child(#{$cols}n+#{$cols}) {
        @include float-span(1, 'last');
      }
    }
  }
}

Demo: http://sassmeister.com/gist/5dab07e1ab0b861e4b4a

  1. We use float-span(1) to span items in a symmetrical grid. It allows us to use the same definition for all items, rather than applying a unique position for every item.
  2. The last item in each row should have no right gutter. The &:nth-child(3n+3) selector targets every third item in all rows. We apply a float-span(1, 'last'), telling Singularity not to add right margin.

Singularity Quick Spanner

You can also make use of my singularity-quick-spanner extension to simplify things even further. It lets you achieve the same result as above with a single line of code:

.footer__blocks {
  @include grid-span(1, 2);

  @include layout(3, $gutter: 0) {
    .footer__block {
      @include thumb-span(3); // Magic! :D
    }
  }
}

Demo: http://sassmeister.com/gist/c2c4ab643165c9da2526

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!