使用scrollTo沿x轴移动

发布于 2024-09-09 05:39:39 字数 2011 浏览 4 评论 0原文

对了,最后一个问题!

我正在创建一个水平组合网站,并正在寻求一些帮助,使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日久见人心 2024-09-16 05:39:39

不要放弃!试试这个,让我知道你想要的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

飘过的浮云 2024-09-16 05:39:39

看来我犯了一个错误,尝试滚动表格,而滚动窗口正是我真正需要做的!工作的 jQuery 如下:

$('#forward').click(function() {
    $.scrollTo('+=560px', 800, { axis:'x' });
});
$('#back').click(function() {
    $.scrollTo('-=560px', 800, { axis:'x' });
});

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:

$('#forward').click(function() {
    $.scrollTo('+=560px', 800, { axis:'x' });
});
$('#back').click(function() {
    $.scrollTo('-=560px', 800, { axis:'x' });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文