gpt4 book ai didi

javascript - "next"和 "previous"按钮在此触摸 slider 插件中不起作用

转载 作者:行者123 更新时间:2023-11-28 10:30:27 25 4
gpt4 key购买 nike

我正在使用 touchSlider 插件:http://www.mobilizetoday.com/freebies/touchslider/examples#ex-6

我将插件的这个确切部分集成到我的网站中(我正在响应)。用手指滑动效果很好,但按钮不起作用。这是我的网站:http://dev.ux-pm.com .要获取 slider 所在的页面,只需将浏览器宽度减小到小于 480px,然后单击 level 1 in detail(蓝色按钮)

HTML代码:

<div class="gallery-holder">
<div class="gallery" id="gallery3">
<div class="holder">
<div class="list">
<div class="item">
<div class="ibox">
level1
</div>
</div>
<div class="item">
<div class="ibox">
level2
</div>
</div>
<div class="item">
<div class="ibox">
level3
</div>
</div>
</div>
</div>
</div>
</div>
<a href="#" class="prev">Prev item</a>
<a href="#" class="next">Next Item</a>
<span id="counter"></span>
</div>
</div>

JS:

 $(document).ready(function(){

$('#gallery3').touchSlider({
mode: 'index',
center: true,
prevLink: 'a.prev',
nextLink: 'a.next',
onChange: function(prev, curr) {
$('#counter').html((curr+1)+'/'+ $('#gallery3').get(0).getCount());
},
onStart: function(){
$('#counter').html('1/' + $('#gallery3').get(0).getCount());
}
});
});

CSS:

body {
margin: 0;
padding: 10px;
font: 14px Helvetica, Arial, sans-serif;
color: #666;
max-width: 800px;
min-width: 300px;
margin: 0 auto;
}

h1, h2 {
margin: 0;
padding: 0 0 10px 0;
font-size: 16px;
color: #333;
}

.box {
width: 96px;
height: 96px;
line-height: 96px;
text-align: center;
color: #FFF;
margin: 2px;
display: block;
text-decoration: none;
overflow: hidden;
position: relative;
}

.box img {
width: 96px;
vertical-align: middle;
}

.box1 {background: red;}
.box2 {background: blue;}
.box3 {background: orange;}

.ibox,
.cbox,
.fbox {
width: 210px;
height: 210px;
line-height: 210px;
text-align: center;
color: #FFF;
margin: 2px;
display: block;
text-decoration: none;
overflow: hidden;
position: relative;
}

.centered .ibox,
.centered .cbox{
margin: 2px auto;
padding: 0 2px;
}


.ibox img {
width: 210px;
vertical-align: middle;
}

.cbox img,
.fbox img{
width: 100%;
vertical-align: middle;
}

.fbox {
width: 600px;
height: 600px;
line-height: 600px;
}

span.delta {
position: absolute;
top: 0;
width: 1px;
text-indent: -9999px;
overflow: hidden;
background: magenta;
}

.ibox span.delta {
height: 210px;
}

.active .box {
outline: 1px dashed green;
}

.gallery-holder {
margin: 0 auto;
outline: 1px dashed #666;
margin: 0 auto 10px auto;
padding: 10px;
}

.gallery {
width: 100%;
overflow: hidden;
}

.gallery div.holder {
width: 100%;
position: relative;
overflow: hidden;
}

.gallery div.list {
margin: 0;
padding: 0;
list-style: none;
width: 9999px;
overflow: hidden;
}

.gallery div.item {
float: left;
}

/*.moving {
background: yellow;
}*/

.debug-item {
padding: 1px 0;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
margin-bottom: -1px;
color: #999;
font-size: 11px;
}

#menu {
margin: 0;
padding: 0;
list-style: none;
}

#menu a {
display: block;
border: 1px solid #ccc;
border-radius: 5px;
-webkit-border-radius: 5px;
padding: 6px 0;
margin-bottom: 6px;
font-size: 16px;
color: #333;
background: #EFEFEF;
text-decoration: none;
text-align: center;
}

a.prev,
a.next,
#moveTo,
a.tablink,
#counter {
border: 1px solid #CCC;
border-radius: 5px;
-webkit-border-radius: 5px;
padding: 6px;
margin-bottom: 6px;
font-size: 16px;
color: #333;
background: #EFEFEF;
text-decoration: none;
}
a.prev {float: left;}
a.next {float: right;}

#moveTo,
#counter {
display: block;
margin: 0 auto;
overflow: hidden;
width: 200px;
text-align: center;
}

.focus .ibox {
outline: 1px dashed green;
}
.focus-old .ibox {
outline: 1px dashed red;
}

#tabs, #tabs2 {
text-align: center;
}
.tablink {
display: inline-block;
overflow: hidden;
width: 20px;
height: 20px;
text-align: center;
margin: 0 2px;
}
a.active {
border-color: #333;
}

#tabs2 .tablink {
display: inline-block;
overflow: hidden;
width: 15px;
height: 15px;
text-align: center;
margin: 0 10px;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
text-indent: -9999px;
}

#tabs2 a.active {
background-color: #666;
}

我拼命地试图找到问题所在,但我不能..有什么帮助吗?谢谢

最佳答案

您的导航元素未嵌套在 gallery3 中,这是插件期望它们所在的位置:

<div id="left2">
<div class="gallery-holder">
<div class="gallery" id="gallery3">
<div class="holder">
<div class="list" style="transition: 0.5s ease; -webkit-transition: 0.5s ease; -webkit-transform: translate3d(60px, 0px, 0px);">
<div class="item active"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>
</div>
</div>
<a href="#" class="prev">Prev item</a>
<a href="#" class="next">Next Item</a>
<span id="counter">1/3</span>

touchSlide 插件在初始化对象范围内查找按钮选择器。 http://touchslider.com/

尝试将它们嵌套在 gallery3 的一侧,但不要嵌套在 holder 的内部。

关于javascript - "next"和 "previous"按钮在此触摸 slider 插件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23553848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com