简体   繁体   English

使用引导程序,使幻灯片向上或向下滚动,而不是向左或向右滚动

[英]Using bootstrap,make slide to scroll up and down, not left or right

I have seen some website has this: they have only one page (actually they have some pages, but only show one at one time) on their homepage, which means they have no vertical scroll bar, but when you put your fingers scroll up and down on the touchpad, the homepage will scroll up or down smoothly,show some different contents. 我见过一些网站有这样的网站:他们的首页上只有一页(实际上他们有几页,但一次只显示一页),这意味着它们没有垂直滚动条,但是当您将手指向上滚动并在触摸板上向下滑动,主页将平滑地上下滚动,显示一些不同的内容。

Just like you have a slide, but the slide go up and down, not left or right. 就像您有一张幻灯片一样,但是幻灯片会上下移动,而不是左右移动。 Sample link: http://tangyan.maxinrui.com/ 样本链接: http : //tangyan.maxinrui.com/

Can somebody show me how to did this, maybe using Bootstrap? 有人可以告诉我如何做到这一点,也许使用Bootstrap吗? Or give me a sample page. 或给我一个示例页面。

Thanks in advance. 提前致谢。

You can make it with buttons, I don't know if you want that. 您可以使用按钮来实现,我不知道您是否想要。

Make a file called extra.js put the following code in it: 创建一个名为extra.js的文件,并在其中添加以下代码:

$(document).ready(function(){
    $('a[href^="#"]').on('click',function (e) {
        e.preventDefault();

        var target = this.hash,
        $target = $(target);

        $('html, body').stop().animate({
        'scrollTop': $target.offset().top
        }, 900, 'swing', function () {
            window.location.hash = target;
        });
    });
});

on the pages the extra.js is loaded all anchor links will scroll. 在页面上extra.js加载所有滚动链接。
(Anchor link is just a link with 'id="one"' 'href="#one"') (锚链接只是带有'id =“ one”''href =“#one”'的链接)
I think when you want to make it scroll when the user scrolls you could hook this up to some javascript. 我认为当用户滚动时要使其滚动时,可以将其连接到某些javascript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM