【发布时间】:2018-10-30 01:27:42
【问题描述】:
我正在为网站使用FullPage.js。对于我的 2-4 部分,我希望背景图像保持固定,以便只有部分中的内容在滚动,而不是背景图像。这是我尝试过的:
#section1 {
background:#ccc;
}
#section2, #section3, #section4 {
background:url('http://placehold.it/1024x768/7777c1/fff') no-repeat;
background-attachment:fixed;
background-size:cover;
background-position:center center;
}
#section5 {
background:#000;
}
#section5 h1 {
color:#fff;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.3/fullpage.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.3/fullpage.min.js"></script>
<div id="fullpage">
<div class="section" id="section1">
<div class="slide"><h1>Simple Demo</h1></div>
<div class="slide"><h1>Only text</h1></div>
<div class="slide"><h1>And text</h1></div>
<div class="slide"><h1>And more text</h1></div>
</div>
<div class="section" id="section2"><h1>No wraps, no extra markup</h1></div>
<div class="section" id="section3"><h1>Just the simplest demo ever</h1></div>
<div class="section" id="section4"><h1>Lorem Ipsum</h1></div>
<div class="section" id="section5"><h1>Lorem Ipsum</h1></div>
</div>
<script type="text/javascript">
var myFullpage = new fullpage('#fullpage', {
licenseKey: 'OPEN-SOURCE-GPLV3-LICENSE'
});
</script>
我希望background-attachment:fixed; 能做到这一点,但背景仍会随着该部分滚动。
【问题讨论】:
标签: css fullpage.js