【发布时间】:2014-11-19 06:34:06
【问题描述】:
您好,我正在尝试创建视差站点。我的代码在每个浏览器中都运行良好。但是我在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>
谁能给我一个解决办法
输出
【问题讨论】: