我在我的网站中使用此代码,并且在桌面浏览器上运行良好。但是,视差无法在手机上使用。
.parallax {
background-image: url("images/pizza.jpg");
height: 400px;
margin-right: 0px;
margin-bottom: 10px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: yellow;
}
<div class="row">
<div class="col-sm-5">
<h4>J.R.R. Tolkien</h4>
<a href="#"><h3>Scroll down ↓</h3></a>
</div>
<div class="col-sm-7">
<div class="parallax"></div>
</div>
</div>