您好,我正在尝试创建一个视差网站。我的代码在每个浏览器中都运行良好。但我在 ipad 上遇到了一些问题。在 ipad background-size: cover 中不起作用。
这是我的代码:
$(document).ready(function(){
$('section[data-type="background"]').each(function(){
var $bgobj = $(this); // assigning the object
$(window).scroll(function() {
// Put together our final background position
var yPos = -($window.scrollTop() / $bgobj.data('speed'));
var coords = '50% '+ yPos + 'px';
// Move the background
$bgobj.css({ backgroundPosition: coords });
});
});
});
#section1 {
background: url(images/hlfs-image.jpg) 0% 0% no-repeat fixed;
min-height: 1000px ;
height: 1000px ;
margin: 0 auto ;
width: 100%;
max-width: 1920px ;
position: relative ;
background-size:cover ;
}
<section id="section1" data-type="background" data-speed="10" class="pages"> </section>
谁能给我一个解决方案
输出
最佳答案
尝试使用
#section1 {
background: url(images/hlfs-image.jpg) 0% 0% no-repeat fixed; min-height: 1000px !important;
height: 1000px !important;
margin: 0 auto !important;
width: 100%;
max-width: 1920px !important;
position: relative !important;
background-size:cover !important;
-webkit-background-size: cover;
}
我的正在处理这个..
关于html - '背景大小 :cover' does not work in ipad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27010477/