gpt4 book ai didi

javascript - 修改单页滚动功能-重叠而不是向上滑动

转载 作者:行者123 更新时间:2023-11-29 21:54:32 25 4
gpt4 key购买 nike

您好,我正在使用这个 js 库来制作一个全页滚动的网站。 http://www.thepetedesign.com/demos/onepage_scroll_demo.html

这是我的 jsfiddle 示例: http://jsfiddle.net/aLjLjxux/

我希望它们保持固定并与以下 div 重叠,而不是将每个元素向上推出 body 。在这个库中是否有这个功能的简单实现,或者是否有一个不同的库可以让我实现这个?

作为引用,它看起来像这样: http://www.facebookgroups.com/除了反转。因为后面出现的 div 会在滚动时与之前的 div 重叠。

<body>
<div class="main">
<section style="background-color: #eaeaea;" class="first"><h1>Hello</h1></section>
<section style="background-color: #dadada;" class="second"><h1>Sup</h1></section>
<section style="background-color: #cacaca;" class="third">yo</section>
</div>
<script type="text/javascript">
$(".main").onepage_scroll({
sectionContainer: "section", // sectionContainer accepts any kind of selector in case you don't want to use section
easing: "ease-out", // Easing options accepts the CSS3 easing animation such "ease", "linear", "ease-in",
// "ease-out", "ease-in-out", or even cubic bezier value such as "cubic-bezier(0.175, 0.885, 0.420, 1.310)"
animationTime: 1000, // AnimationTime let you define how long each section takes to animate
pagination: true, // You can either show or hide the pagination. Toggle true for show, false for hide.
updateURL: false, // Toggle this true if you want the URL to be updated automatically when the user scroll to each page.
beforeMove: function(index) {$(this).css("position", "fixed");}, // This option accepts a callback function. The function will be called before the page moves.
afterMove: function(index) {}, // This option accepts a callback function. The function will be called after the page moves.
loop: false, // You can have the page loop back to the top/bottom when the user navigates at up/down on the first/last page.
keyboard: true, // You can activate the keyboard controls
responsiveFallback: false, // You can fallback to normal page scroll by defining the width of the browser in which
// you want the responsive fallback to be triggered. For example, set this to 600 and whenever
// the browser's width is less than 600, the fallback will kick in.
direction: "vertical" // You can now define the direction of the One Page Scroll animation. Options available are "vertical" and "horizontal". The default value is "vertical".
});
</script>
</body>

谢谢。

最佳答案

您链接的网站正在使用 pagePiling.js插入。它甚至支持不支持 CSS3 的旧浏览器,这与您要修改的 onepage-scroll 不同。

无需修改您正在使用的那个。反正不会那么部落化。

如果你想反转它,那么你最好从pagePiling.js开始,你的工作量会少很多。

关于javascript - 修改单页滚动功能-重叠而不是向上滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27134458/

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