javascript - FullPage JS固定背景不工作

标签 javascript css jsfiddle fullpage.js

我正在尝试获得固定背景以使用 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/

相关文章:

javascript - 不要在 IE 中使用 Bootstrap 显示网站

css - 顶部导航列表项边距错误

javascript - 使用 jQuery 将第一行添加到表中

javascript - V8 是否检测 int 变量并更有效地处理它们?

javascript - 为什么 w3.css 侧导航栏在我的页面上不起作用?

html - 使用 bootstrap 3 对齐表单元素的网格系统

debugging - 如何调试jsfiddle中的js

javascript - 无法为 HTML、JS 代码运行 jsfiddle

javascript - JSFiddle 提供的额外 CSS

javascript - 如何从正方形中删除 trlabel 值和 tlLabel 值,但它应该出现在热图图表的工具提示中?