使用scrollTo沿x轴移动
对了,最后一个问题!
我正在创建一个水平组合网站,并正在寻求一些帮助,使用scrollTo插件来创建下一个/上一个样式导航,以便用户快速浏览图像。
我的 HTML 是:
<div id="contentRight">
<ul id="direction">
<li id="next"><a id="forward">Next</a></li>
<li id="prev"><a id="back">Previous</a></li>
</ul>
<table id="work">
<tr>
<td id="horseOneImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseTwoImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseThreeImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseFourImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseFiveImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseSixImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseSevenImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseEightImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
</tr>
</table>
</div>
我当前失败的 jQuery 是:
$('#forward').click(function() {
$('table#work tr').stop().scrollTo( '+=636', 800, {axis:'x'} );
});
$('#back').click(function() {
$('table#work tr').stop().scrollTo( '-=636', 800, {axis:'x'} );
});
不幸的是,当单击 #forward 或 #back 时,表 tr 不会移动。
有人有什么想法吗?
有关额外信息 - 使用该表格是因为这似乎是没有固定宽度的动态水平网站的最佳实践。
Right, last question for a while!
I am creating a horizontal portfolio site and am looking for some help using the scrollTo plugin in creating a next/previous style navigation for the user to flick through the images.
My HTML is:
<div id="contentRight">
<ul id="direction">
<li id="next"><a id="forward">Next</a></li>
<li id="prev"><a id="back">Previous</a></li>
</ul>
<table id="work">
<tr>
<td id="horseOneImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseTwoImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseThreeImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseFourImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseFiveImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseSixImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseSevenImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
<td id="horseEightImage" class="mainImage"><img class="large" src="media/images/horse.jpg" alt="" /></td>
</tr>
</table>
</div>
And my current failing jQuery is:
$('#forward').click(function() {
$('table#work tr').stop().scrollTo( '+=636', 800, {axis:'x'} );
});
$('#back').click(function() {
$('table#work tr').stop().scrollTo( '-=636', 800, {axis:'x'} );
});
Unfortunately the table tr does not move when #forward or #back is clicked.
Anyone any ideas why?
For extra info - the table is used as this appears to be best practice on dynamic horizontal sites that are without a fixed width.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要放弃!试试这个,让我知道你想要的http://avinash.tk/dan/
刚刚修改了上一篇文章中的代码,看看scrollTo和水平表格
don't give up !! try this and let me is this want you want http://avinash.tk/dan/
Just modified the code in your previous post , Have a Look scrollTo and horizontal tables
看来我犯了一个错误,尝试滚动表格,而滚动窗口正是我真正需要做的!工作的 jQuery 如下:
It appears that I made the mistake of trying to scroll the table when scrolling the window was what I actually needed to do! The working jQuery is as follows: