[英]Why Parallax effect doesn't work on mobile devices?
我正在使用對主要背景具有視差效果的Laravel 5.4應用程序。 它可以在桌面上完美運行,也可以通過開發人員工具在各種屏幕尺寸上完美運行,但是當通過移動設備訪問同一頁面時,不會顯示視差效果。 我添加了負責所需效果的代碼塊。
#promo {
min-height: 25em;
width: 100%;
position: relative;
z-index: 0;
}
<body>
<section id="promo" style="background: url({{$mainImg->path}}) 50% 0px repeat fixed; background-size:cover;">
</section>
</body>
固定的背景位置無法在移動設備上正常工作,因此,要解決此問題,您需要做一個簡單的技巧,而不是給出section
背景圖片並使其固定,請嘗試將section:before
設置為position:fixed;
並為其提供背景圖像。
#promo:before{
position:fixed;
width:100%;
height:100%;
left:0;
top:0;
background:url('image.jpg');
}
玩z-index,然后就可以開始了。 嘗試讓我知道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.