简体   繁体   English

如何让我的页面在滚动 Jquery 或 CSS (或任何其他方式)上滑动

[英]How can i make my page slide on scroll Jquery or CSS (or any other way)

I am wondering that how I can make my page slide when user scrolls the page.我想知道当用户滚动页面时如何使页面滑动。 I have searched for solutions all over the web but I have found nothing.我在整个 web 中搜索了解决方案,但我什么也没找到。 One solution had so much code it wasn't even worth it.一个解决方案有这么多代码,甚至不值得。

Is there an efficient way or using a CDN that will allow me to do this?有没有一种有效的方法或使用 CDN 可以让我这样做?

Note: its a smooth scrolling effect that keeps sliding subtly after you scroll up or down instead of abrupt scrolling as is the default.注意:它是一种平滑的滚动效果,在您向上或向下滚动后会保持微妙的滑动,而不是默认的突然滚动。

var html = $('html');
$('html').scroll(function() {
    html.animate({},500, 'swing');
});

But of course that doesn't make much sense.但这当然没有多大意义。

I'm wondering if i should detect the direction of the scroll and based on that i add top:50px inside the CSS in the animate part or top:-50px if scroll direction is up.我想知道我是否应该检测滚动的方向,并基于此在动画部分的 CSS 内添加 top:50px,如果滚动方向向上,则添加 top:-50px。

What do you think?你怎么看? I'm not sure that would work.我不确定那会奏效。

I think you are talking about you need a custom jQuery plugin for scrolling.我想你在说你需要一个自定义的 jQuery 插件来滚动。 You can try http://manos.malihu.gr/jquery-custom-content-scroller/ And there are two code examples:您可以尝试http://manos.malihu.gr/jquery-custom-content-scroller/并且有两个代码示例:

  1. http://manos.malihu.gr/code-example/responsive-custom-scrollbar-with-css3-media-queries/ http://manos.malihu.gr/code-example/responsive-custom-scrollbar-with-css3-media-queries/
  2. http://manos.malihu.gr/add-a-custom-scrollbar-to-your-twitter-widget/ http://manos.malihu.gr/add-a-custom-scrollbar-to-your-twitter-widget/

You have also option to download the project from first URL.您还可以选择从第一个 URL 下载项目。

This is the simple example plugin and very helpful.这是一个简单的示例插件,非常有用。

暂无
暂无

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

相关问题 向下滚动时,有什么方法可以使这两个框从两侧滑动? - Is there any way i can make this two boxes slide in from each side when scroll down? 使用jQuery,如何向页面添加“滚动计数器”? - Using jQuery, how can I add a “scroll counter” to my page? 如何在 HTML CSS 中使我的滚动始终位于页面的末尾。 我希望我的卷轴总是在页面的末尾 - How do I make my scroll always in the end of the page in HTML CSS. I want my scroll to always be at the end of the page Iphone-Web,jQuery:当用户在滑块上滑动手指时,如何使网页上的滑块滑动? - Iphone-web, jQuery: How can i make slider on web page to slide as the user slides finger on slider? CSS和jQuery创建一个滑动面板,该面板将另一个div推向水平方向,而不是向下推,右侧面板必须填充所有页面 - CSS and jQuery to make a slide panel, that push the other div horizontal, and not down, and the right panel has to fill all the page 当页面滚动到达页脚时,如何使粘性侧边栏向上滚动? - How can I make my sticky sidebar to scroll up when page scroll reaches the footer? 如何给幻灯片链接以重定向到其他页面 - how I can give link to slide to redirect to other page 如何让页面滚动到一个元素? - How can I make the page scroll to an element? 有没有其他方法可以让我摆脱这个问题,因为我的 page.click() function 不起作用 - Is there any other way so that i can get rid of this problem as my page.click() function is not working 问题 jQuery幻灯片强制我的页面滚动到顶部 - issue | JQuery slide forces my page to scroll to the top
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM