我开始使用 Susy 并且有一些我想完成但我不知道如何完成的事情,尽管我正在阅读 Susy 的文档和在线教程。
我有这个html:
<div class="page">
<nav>nav</nav>
<div class="main">
<div class="summary">
summary
</div>
<div class="content">
content
</div>
</div>
<footer>footer</footer>
</div>
以及这些 Susy 设置:
$total-columns: 12;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: $gutter-width;
$show-grid-backgrounds: true;
@include border-box-sizing;
// breakpoint variables
$M: 30em;
$L: 50em;
这个scss:
.page {
@include container;
@include susy-grid-background;
nav {
@include at-breakpoint($M) {
@include span-columns(2,12);
}
}
.main {
@include at-breakpoint($M) {
@include span-columns(10 omega,12);
}
.summary {
@include at-breakpoint($L) {
@include span-columns(2 omega,10);
}
}
.content {
@include at-breakpoint($L) {
@include span-columns(8,10);
}
}
}
footer {clear: both;}
这可以按预期工作,内容完全是流动的,具有最大宽度。但是,我想要相同的行为,但从 4 列布局开始,然后更改为 8 列,然后更改为 12 列。
我这样做:
$total-columns: 4;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: $gutter-width;
$show-grid-backgrounds: true;
@include border-box-sizing;
// breakpoint variables
$M: 30em;
$L: 50em;
和scss:
.page {
@include container;
@include susy-grid-background;
// Now create a media-query breakpoint at the min-width of 30em and use a larger grid and modify the layout
@include at-breakpoint($M 8) {
// This will create a new container with a total of 8 columns
@include container;
@include susy-grid-background;
// Now modify the inner elements to their new home
nav { @include span-columns(2,8); }
.main { @include span-columns(6 omega,8); }
}
@include at-breakpoint($L 12) {
// This will create a new container with a total of 12 columns
@include container;
@include susy-grid-background;
// Now modify the inner elements to their new home
nav { @include span-columns(2,12); }
.main {
@include span-columns(10 omega,12);
.content {
@include span-columns(8,10);
}
.summary {
@include span-columns(2 omega,10);
}
}
}
footer {clear: both;}
}
这也可以,但我不能像第一个示例那样使所有布局都流动。例如,450px 宽的 4 列布局不会填满视口。同样的情况发生在 768px,8 列不填满视口。我希望布局始终填充可用宽度,如第一个示例所示,并根据定义的断点更改列。
这是正常的 Susy 行为还是有可能以其他方式做到这一点?
对不起,如果这是一个新手问题,但我才刚刚开始,我想在实际项目中使用 Susy 之前先把事情弄清楚。
谢谢。