我一直在寻找文档,但似乎找不到在 jQuery mobile 中制作可滚动水平导航栏的方法,有人完成了吗?
看到我想要类似 valums.com/files/2009/menu/final.htm 之类的东西,但只是用于导航,因此您可以向左或向右滑动以获取更多菜单项
猜猜这就是你想要的。
HTML。
<div class="categories">
<ul>
<li><span><a href="">ABC</a></span></li>
<li><span><a href="">DEF</a></span></li>
<li><span><a href="">GHI</a></span></li>
<li><span><a href="">JKL</a></span></li>
</ul>
</div>
jQuery
$(function(){
var step = 1;
var current = 0;
var maximum = $(".categories ul li").size();
var visible = 2;
var speed = 500;
var liSize = 120;
var height = 60;
var ulSize = liSize * maximum;
var divSize = liSize * visible;
$('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
$(".categories ul li").css("list-style","none").css("display","inline");
$(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");
$(".categories").swipeleft(function(event){
if(current + step < 0 || current + step > maximum - visible) {return; }
else {
current = current + step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
$(".categories").swiperight(function(){
if(current - step < 0 || current - step > maximum - visible) {return; }
else {
current = current - step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
});
但无法得到它可以有人帮助我......谢谢