製作,其大小,你希望你的滑塊可見藥水是一個容器元素,然後添加可以到處移動轉移哪些內容,目前可見的子元素:
<style>
#container {
position : relative;/*necessary so its child can be positioned absolutely*/
width : 500px;
height : 200px;
overflow : hidden;
}
#container ul {
position : absolute;
top : 0;
left : 0;
list-style : none;
width : <total number of LI elements times their width, so eight LI elements would be 800>px
}
#container li {
width : 100px;
float : left;
}
</style>
<div id="container">
<ul>
<li>item 1</li>
<li>item 2</li>
...
</ul>
</div>
<script>
$(function() {
$('#left-nav-button').on('click', function() {
//use `.animate()` or `.css()` to move the UL element to the left (Hint: negative `left` value)
});
$('#right-nav-button').on('click', function() {
//use `.animate()` or `.css()` to move the UL element to the right
});
});
</script>
這裏在jsfiddle上的簡單演示:http://jsfiddle.net/qML6L/