0

这就是我想要实现的目标: 在此处输入图像描述

-

-

我在这里想念什么?我想将我的无序列表保留在一行上并溢出:隐藏......我知道我也可以以一种我可以将箭头绝对定位在高 z-index 上的方式重写 html,而 li 的在较低的 z-index 上,但我不想这样做。我希望 ul 自然流动,但我对此有疑问。哪个是首选方法?

这就是我到目前为止所得到的:http: //jsfiddle.net/pTaTc/

HTML

<ul>
<li><a href="#">Category 1</a></li>
<li><a href="#">Category 2</a></li>
<li><a href="#">Category 3</a></li>
<li><a href="#">Category 4</a></li>
<li><a href="#">Category 5</a></li>
<li><a href="#">Category 6</a></li>
<li><a href="#">Category 7</a></li>
<li><a href="#">Category 8</a></li>
<li class="arrow-wrapper">
    <a href="#" class="left-arrow"><</a>
    <a href="#" class="right-arrow">></a>
</li>
</ul>

CSS

    * { font-family: arial; font-size: 1em; }

    ul { position: relative; background: black; padding: 1em; }
    li { display: inline; }
    a { color: white; text-decoration: none; padding: 1em 2em; display: inline-block; }
    .arrow-wrapper { background: black; }
    .arrow-wrapper a { color: #54bdff; font-size: 2em; font-weight: bold; line-height:.75; }
    .left-arrow { position: absolute; top: 0; bottom: 0; left: 0; }
    .right-arrow { position: absolute; top: 0; right: 0; bottom: 0; }




    /* Black gradient for arrows */
    .left-arrow {
    background: -moz-linear-gradient(left,  rgba(0,0,0,1) 50%, rgba(0,0,0,0) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(50%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left,  rgba(0,0,0,1) 50%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left,  rgba(0,0,0,1) 50%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left,  rgba(0,0,0,1) 50%,rgba(0,0,0,0) 100%); /* IE10+ */
    background: linear-gradient(to right,  rgba(0,0,0,1) 50%,rgba(0,0,0,0) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#00000000',GradientType=1 ); /* IE6-9 */
    }

    .right-arrow {
    background: -moz-linear-gradient(left,  rgba(0,0,0,0) 0%, rgba(0,0,0,1) 50%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,0,0,0)), color-stop(50%,rgba(0,0,0,1))); /* Chrome,Safari4+         */
    background: -webkit-linear-gradient(left,  rgba(0,0,0,0) 0%,rgba(0,0,0,1) 50%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left,  rgba(0,0,0,0) 0%,rgba(0,0,0,1) 50%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left,  rgba(0,0,0,0) 0%,rgba(0,0,0,1) 50%); /* IE10+ */
    background: linear-gradient(to right,  rgba(0,0,0,0) 0%,rgba(0,0,0,1) 50%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#000000',GradientType=1 ); /* IE6-9 */    
    }

一如既往,非常感谢您的帮助!

4

1 回答 1

2

添加white-space: nowrap;到您的ul.

有关更多信息white-space

于 2013-06-05T22:30:08.997 回答