[英]Div not confirming to grid. Defined an 8 column grid and elements are binding to 4 column. Susy
My div is not matching up to my grid. 我的div与我的网格不匹配。 It's an 8 container grid and when I tell the element to span(2), it acts as if the grid were 4. Is this because I'm not defining a global grid in $susy?
它是一个8容器的网格,当我告诉元素span(2)时,它的作用就好像网格是4。这是因为我没有在$ susy中定义全局网格吗?
Some contextual code: 一些上下文代码:
First I defined a container grid: 首先,我定义了一个容器网格:
#grid{
@include container(8);
gutter-width: 5%;
}
Then I added it to the html: 然后我将其添加到html中:
<main id="grid">...</div>
Then I nested the div in css: 然后我将div嵌套在CSS中:
#object1{
@extend %object;
@include span(2);
}
and added it to the html 并将其添加到html
<main id="grid">
<div id="object1">a</div>
</main>
You don't have to pass the explicit context to every single container/span element if you set it globally . 如果在全局范围内进行设置,则不必将显式上下文传递给每个容器/跨度元素。 Susy (and any other Sass plugin) is not aware of the DOM, and so it is not aware that
#object1
is inside #grid
which has been set to 8 columns
. Susy(和任何其他Sass插件)不知道DOM,因此不知道
#object1
在#grid
,该#grid
已设置为8 columns
。
Every item needs context from somewhere. 每个项目都需要某个地方的上下文。 If you don't pass it in explicitly, Susy checks the global settings, which default to
4 columns
. 如果您没有明确传递它,Susy将检查全局设置,默认为
4 columns
。 If you change the global setting to 8
, then you don't need to pass context into your mixins. 如果将全局设置更改为
8
,则无需将上下文传递到mixins中。 The with-layout
mixin is just one way to change the global setting temporarily, for a block of nested code. 对于一组嵌套代码
with-layout
混合是暂时更改全局设置的一种方法。
.default {
@include span(2); // uses global default of 4
}
$susy: layout(8);
.custom {
@include span(2); // uses global setting of 8
@include with-layout(4) {
@include span(2); // uses temporary setting of 4
}
@include span(2); // uses global setting of 8 again
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.