【问题标题】:Susy: change the number of columns according to screen sizesusy:根据屏幕大小改变列数
【发布时间】:2012-04-04 16:34:29
【问题描述】:

在 Compass/Sass 插件 Susy 中,您可以设置 _base.scss 文件中的列数。

对于桌面视图,我喜欢有 12 列。但是,对于移动视图来说,这列太多了。有没有办法更改移动显示的列数?

(我正在制作响应式网页设计,因此该网站的桌面版和移动版都将共享同一个 _base 文件)。

谢谢!

【问题讨论】:

标签: css sass susy-compass


【解决方案1】:

更新: Susy 1.0 现在使用 at-breakpoint mixin 内置了此功能。请参阅the official site 上的文档。

是的,你可以!我正在将此功能烘焙到 Susy 的核心中,但目前您必须自己做。这是我的方法(需要最新的 Compass 和 Sass alpha):

// for mobile layouts
$total-cols: 4;

.container {
  @include container;
}

// for desktops
@media all and (min-width: 30em) {
  $total-cols: 12;

  .container {
    @include container;
  }
}

根据需要对每个断点重复。您还可以创建简单的 mixin 来帮助您:

@mixin desktop() {
  @media all and (min-width: 30em) {
    $current-total: $total-cols; // remember current column setting
    $total-cols: 12;             // change column setting for new context

    @content;                    // apply content with new column-count

    $total-cols: $current-total; // return original column setting
  }
}

.container {
  @include container;

  @include desktop {
    @include container;
  }
}

【讨论】:

    猜你喜欢
    • 2014-11-02
    • 2016-12-26
    • 1970-01-01
    • 2013-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-13
    • 2020-09-04
    相关资源
    最近更新 更多