我使用脚本根据鼠标移动/手机移动将背景位置移动了一定的像素距离。然而,我想不出一种方法来总是让背景延伸包含div的整个宽度和高度。该脚本可以根据鼠标移动来移动背景。但是它移动了太多的背景图像,造成了空白。
看看这把小提琴,你就会明白我的意思了。
小提琴:http://jsfiddle.net/K9Ae7/2/
HTML:
<section id="court-fitness" data-parallaxify-background-range="30"></section>CSS:
#court-fitness {
height: 500px;
width: 100%;
background:url('https://www.tourresource.com/Board/Themes/SMF_Grunge/images/bg.jpg');
background-repeat: no-repeat;
}JS:
$('#court-fitness').hover(function () {
$(this).parallaxify({
parallaxBackgrounds: true,
useMouseMove: true,
useGyroscope: true,
inputPriority: 'mouse'
});
},
function () {
$(this).parallaxify('destroy');
});脚本的其余部分都在小提琴里。谢谢。
发布于 2014-02-28 07:25:16
看看这个:
#court-fitness {
height: 500px;
width: 110%;
margin-left: -5%;
margin-top: -5%;
background:url('https://www.tourresource.com/Board/Themes/SMF_Grunge/images/bg.jpg');
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
z-index: -1;
}https://stackoverflow.com/questions/22082682
复制相似问题