简体   繁体   English

div未确认到网格。 定义了一个8列网格并将元素绑定到4列。 与Susy

[英]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>

edit: fixed (must define context even in child elements. why is that? if i can set span according to any grid amount that i want, then what's the point of all this with-layout and context following hokey pokey? If span doesn't read context from the parent element then what the hell is the point of susy?) 编辑:固定(即使在子元素中也必须定义上下文。为什么呢?如果我可以根据自己想要的任何网格数量设置跨度,那么在hokey pokey之后所有这些布局和上下文的意义是什么?从父元素中读取上下文,那么可疑之处到底是什么?)

Here's the result 这是结果

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM