gpt4 book ai didi

jquery - Stellar.js 位置问题

转载 作者:技术小花猫 更新时间:2023-10-29 12:03:28 29 4
gpt4 key购买 nike

我正在尝试使用 Stellar.js 来实现视差效果,但是 data-stellar-ratio=""标签让我的元素错位了。我有这个代码:

<div class="slider" id="yours" data-slide="3" data-stellar-background-ratio="0.5">
<div class="container">
<div class="outer-ring" data-stellar-ratio="0.6">
<div class="inner-ring" data-stellar-ratio="-0.6" data-stellar-vertical-offset="0">
<div class="core" data-stellar-ratio="-0.3" data-stellar-vertical-offset="0"></div></div></div></div></div>

使用这些 CSS:

.outer-ring {
width: 635px;
height: 635px;
background: url(../img/conheca/wheel-1.png) no-repeat;
position: absolute;
top: 50%;
margin-top: -317px;
left: 50%;
margin-left: -317px;
}

.inner-ring {
width: 478px;
height: 478px;
background: url(../img/conheca/wheel-2.png) no-repeat;
position: relative;
margin: 0px auto;
}

.core {
width: 360px;
height: 360px;
background: url(../img/conheca/wheel-3.png) no-repeat;
position: relative;
margin: 0px auto;
}

当 Stellar“data-ratio”不在标签中时,它很合适,但是当我输入这个参数时,它会改变 .inner-ring 和 .core 的“top”。

我在水平定位时遇到了这样的问题,.container div 有“margin: 0 auto”,子元素在 div 有“position: relative”时离开了 div,但我砍掉了“margin”部分Stellar 脚本中的代码并且它有效。

抱歉,如果我有点困惑,但这件事让我发疯,因为我一直在关注教程 (http://webdesign.tutsplus.com/tutorials/complete-websites/create-a-parallax- scrolling-website-using-stellar-js/) 没有提到这个,也没有提到 Stellar.js 网站。谢谢。

最佳答案

确保所有父元素都有position: relative?

此外,您还可以在调用脚本时设置偏移量,如果您只打算使用垂直滚动,则只需关闭水平滚动即可:

  $(window).stellar({
horizontalScrolling: false,
verticalOffset: 0,
horizontalOffset: 0
});

祝你好运!

关于jquery - Stellar.js 位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690777/

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