【问题标题】:Horizontal list with Susy grid带有 Susy 网格的水平列表
【发布时间】:2013-08-26 17:55:30
【问题描述】:

我想构建一个适合 Susy Grid 的类似于 android 的主导航。它看起来像这样:

代码在这里:

HTML:

<div class="container">
    <nav>
        <ul class="horizontal-list">
            <li>
                <a href="#">One</a>
            </li>
            <li>
                <a href="#">Two</a>
            </li>
            <li>
                <a href="#">Three</a>
            </li>
            <li>
                <a href="#">Four</a>
            </li>
        </ul>
    </nav>
</div>

SASS:

header.main {
    height: $headerHeight;
    background: url('images/headerBackground.gif');

    .container {
        @include container;
        @include susy-grid-background;

        nav {
            @include span-columns(8);

            ul.horizontal-list {
                @include horizontal-list;
                overflow: visible;

                li {
                    @include isolate-grid(2, 8);

                    padding: 0;
                    display: table;
                    a {
                        // vertical alignment
                        display: table-cell;
                        height: $headerHeight / 2;
                        padding-bottom: 2px;
                        vertical-align: bottom;

                        // appearance
                        color: $greyLight;
                        font-size: 18px;
                        text: {
                            transform: uppercase;
                            decoration: none;
                        }

                        // hover
                        position: relative;
                        &:before {
                            content: '';
                            display: block;
                            width: $headerUnderlineGap;
                            background: $black;
                            height: $headerHeight;
                            position: absolute;
                            top: 0;
                            margin-left: -$headerUnderlineGap + 1;
                        }

                        &:hover {
                            color: $white;

                            &:after {
                                content: '';
                                display: block;
                                background: $cyanLight;
                                width: 114%; // TODO check why space(2, 8) does not work
                                height: 4px;
                                position: absolute;
                                margin: -1px 0 0 1px;
                            }
                        }
                    }
                }
            }
        }
    }
}

我觉得将&amp;:after 元素的宽度设置为114% 而不是space(2, 8) 有点笨拙。谁能告诉我,如何设置一个带有 Susy 网格和连续下划线的水平导航,它一直悬停到下一个 li 元素。

提前致谢!

【问题讨论】:

    标签: sass compass-sass susy-compass underline horizontallist


    【解决方案1】:

    space(2,8) 在这种情况下不起作用,因为8 实际上不是上下文:2 是。你只需要space(2,2)

    【讨论】:

    • 嘿埃里克!非常感谢,效果很好!想了半天。您能否告诉我 2 是实际上下文是怎么来的。是因为每个 li 元素都有 2 列吗?再次感谢你!再见,Niels ps:很遗憾我不能投票给你,因为我需要至少 15 个声望……:/
    • 是的,上下文始终与您从同一位置的块级元素获得的跨度相同。如果您想找到某个元素的上下文,只需设置 display: block; 并查看它的作用。在这种情况下,您的 :before 元素位于跨越 2li 内 - 所以上下文是 2
    猜你喜欢
    • 2014-08-05
    • 1970-01-01
    • 2019-12-05
    • 2015-03-02
    • 2018-03-03
    • 1970-01-01
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多