首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Susy嵌套网格

Susy嵌套网格
EN

Stack Overflow用户
提问于 2013-04-03 09:22:21
回答 1查看 717关注 0票数 1

我创建了一个susy网格,并尝试将其用于复杂的嵌套导航。我遇到的问题是,我想在页眉的作用域中有一个0em $的间隔宽度(我使用导航的标记),但是在页面的其余部分,我想有一个1em间隔。我的导航栏是100%的屏幕宽度,理想情况下能够流畅地处理十进制列。

以下是我正在使用的内容:

标题

代码语言:javascript
复制
$container-width: 100%
@include container

// basic div configuration for all of the various horizontal navigations etc 
> div

    // do something here


// do some one off grid math to help with the drop down navigation system
#main

    > ul
        @include horizontal_ul_structure(5,5)
        // approximate the size of the li element
        // 
        > li

mixin (horizontal_ul_structure):现在嵌套工作正常,悬停ul应该是100%宽度。因此,我在1列的上下文中将其设置为12列。

代码语言:javascript
复制
@mixin horizontal_ul_structure($parent, $elements)

    // best if this works as no decimal otherwise screws up everything!
    $element_size: $parent / $elements
    // assumes that it will be called in the context of a ul
    // span the parent # number of elements across
    @include span-columns($parent)

    // now make sure that the child spans the proper amount of elements with no overflow
    > li
        background-color: gray
        @include span-columns($element_size, $parent)

        &:last-of-type      

            @include span-columns($element_size omega, $parent)

        // do a clever little hack to keep the anchor tags looking correct? 
        > a         

            position: relative
            width: $column-width + $gutter-width
            left: $gutter-padding/2
            height: 100%
            background-color: brown

在这里,如果您注意到我正在使用的锚标记hack,那么它实际上将锚标记扩展到li元素之后一点,以防止我不工作的间隔。

有没有什么办法可以去掉这种间隔宽度,然后为应用程序的不同部分创建另一个网格?

有没有办法命名susy配置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-04 05:13:48

有几个选项。

1)如果你没有排水沟,你就不需要Susy。数学计算很简单,您不需要担心十进制列。

代码语言:javascript
复制
li {
  float: left;
  width: percentage($elements/$parent);
  &:last-of-type {
    float: right;
  }
}

2)您可以使用with-grid-settings() { ... } mixin将任何代码块包装在您选择的不同网格中。可能是这样的:

代码语言:javascript
复制
@mixin horizontal_ul_structure($parent, $elements) {
  @include span-columns($parent);

  @include with-grid-settings($elements, $gutter-width: 0) {
    > li {
      @include isolate-grid(1);
    }
  }    
}

如果您只是根据需要更改上下文,您将永远不会有十进制列。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15777299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档