gpt4 book ai didi

javascript - FullPage JS固定背景不工作

转载 作者:太空宇宙 更新时间:2023-11-04 02:14:12 27 4
gpt4 key购买 nike

我正在尝试获得固定背景以使用 Fullpage JS。无论我做什么,背景都留在那里,或者根本不出现。我尝试了一个 JS Fiddle,但我也根本无法让它工作。 https://jsfiddle.net/jpking72/jqa7wapt/9/

<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.8.4/jquery.fullPage.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.8.4/jquery.fullPage.js"></script>
<style type="text/css">

#fullsite {
background-attachment:fixed;
}

#section1 {
background:url(/images/pwHoustonDowntown.jpg) no-repeat 0 0 fixed / cover;
}

#section2 {
background-color:#CCCCCC;
}

#section3 {
background:url(/images/pwHoustonWindow2.jpg) no-repeat 0 0 fixed / cover ;
}

</style>
<script type="text/javascript">

$(document).ready(function () {
$("#fullsite").fullpage({

})

})

</script>
</head>
<body>
<div id="fullsite">
<div class="section" id="section1">
<h1>
Section 1
</h1>
</div>
<div class="section" id="section2">
<h1>
Section 2
</h1>
</div>
<div class="section" id="section3">
<h1>
Section 3
</h1>
</div>
</div>
</body>
</html>

最佳答案

That's a bug in some browsers.与 fullpage.js 无关。 Fullpage.js 使用 css3 的 translate3d 属性,这是导致某些浏览器中错误的原因。

要解决这个问题,您有两个选择:

  • 在 fullpage.js 选项中使用 css3:false。它不会那么流畅,但您将拥有固定的背景。
  • 使用scrollBar:true。你会得到一个滚动条,它可能不会那么流畅。

正如您在 fixedBackgrounds.html provided in in fullpgae.js 中看到的那样,它使用 css3:false。

        $('#fullpage').fullpage({
verticalCentered: false,
//to avoid problems with css3 transforms and fixed elements in Chrome, as detailed here: https://github.com/alvarotrigo/fullPage.js/issues/208
css3:false
});

关于javascript - FullPage JS固定背景不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39171093/

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