这就是我想要实现的目标:
我在这里缺少什么?我希望将我的无序列表放在一行并且溢出:隐藏...我知道我也可以用一种方式重新编写html,我可以将箭头放在高z-index上,而且在较低的z指数上,但我不想这样做。我希望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 */
}
与往常一样,非常感谢您的帮助!