【问题标题】:Override span-columns() at-breakpoint in SUSY在 SUSY 中的断点处覆盖 span-columns()
【发布时间】:2013-09-25 16:28:41
【问题描述】:

问题已被提出,但解决方案对我没有任何帮助。

How to override span-columns at different breakpoint in SUSY

screen.css.scss

// Settings

$total-columns  : 6;
$column-width   : 4em;
$gutter-width   : 1em;
$grid-padding   : $gutter-width;

$tablet         : 8;
$desktop         : 12;

// Layout

body {
    @include container($total-columns, $tablet, $desktop);
    .logo {
        @include span-columns(4);
    }
    nav {
        @include span-columns(2 omega);
    }
}

@include at-breakpoint($tablet) {
    .logo {
        @include span-columns(5, $tablet);
    }
    nav {
        @include span-columns(3 omega, $tablet);
    }
}

@include at-breakpoint($desktop) {
    .logo {
        @include span-columns(1, $desktop);
    }
    nav {
        @include span-columns(11 omega, $desktop);
    }
}

这是结果:http://jsfiddle.net/jmdcp/1/

更改浏览器宽度时,列不会调整大小。即使在平板电脑和桌面断点处,它们也会保持默认比率(span-columns(4) 和 span-columns(2 omega))。 我真的不明白我做错了什么。

【问题讨论】:

    标签: grid susy-compass


    【解决方案1】:

    看起来像级联特异性问题。您的初始跨度设置嵌套在主体选择器下。您的断点覆盖不是。如果你将它全部嵌套在 body 下,或者取消嵌套它的初始设置:

    body {
      @include container($total-columns, $tablet, $desktop);
    }
    
    .logo {
      @include span-columns(4);
      @include at-breakpoint($tablet) {
        @include span-columns(5);
      }
      @include at-breakpoint($desktop) {
        @include span-columns(1);
      }
    }
    
    nav {
      @include span-columns(2 omega);
      @include at-breakpoint($tablet) {
        @include span-columns(3 omega);
      }
      @include at-breakpoint($desktop) {
        @include span-columns(11 omega);
      }
    }
    

    【讨论】:

    • 谢谢,确实是这个问题!有没有办法让 CSS 更干一点?
    • 是的,如果您需要在断点内覆盖宽度,请使用 width: columns(11); 而不是例如@include span-columns(11 omega);。您可能有时(在徽标上)还必须使用 margin-right: gutter(); 覆盖排水沟。
    • 好的,看起来效果很好。谢谢,你真的很有帮助!
    猜你喜欢
    • 2017-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多