带有Susy网格的水平列表

时间:2013-08-23 15:48:14

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

我想构建一个类似主要导航的机器人,适合Susy Grid。它看起来像这样:

enter image description here

代码在这里:

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;
                            }
                        }
                    }
                }
            }
        }
    }
}

我觉得将&:after元素的宽度设置为114%而不是space(2, 8)会有点麻烦。任何人都可以告诉我,如何设置一个带有Susy网格和连续下划线的水平导航,它会一直徘徊到下一个li元素。

提前致谢!

1 个答案:

答案 0 :(得分:2)

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