내 배경 이미지에 대해 간단한 시차 효과를 만들기 위해 노력하고 있습니다. 모든 것이 작동하는 것 같지만 배경 이미지가 첫 번째 스크롤에서 점프 한 다음 작동합니다! 나는 그것이 점프 계속 이유를 알아낼 수 없습니다, 실시간 미리보기 : http://loai.directory/gallery배경 이미지가 첫 번째 스크롤에서 점프합니다.
HTML :
<div class="topSection parallax">
<div class="content">
</div>
</div>
CSS :
#page {
background-color: #3F8AE4;
padding-top: 80px;
text-align: left;
}
/*Wrappers*/
.wrapper {
background-color: #ffffff;
}
.wrapper.A {
background-color: #EDEDED;
border-top: 1px solid rgba(0,0,0,0.1);
border-bottom: 1px solid rgba(0,0,0,0.1);
}
/*Content Container*/
.content {
width: 1024px;
padding: 50px 20px;
margin: auto;
overflow: hidden;
position: relative;
}
/*Top Section*/
.topSection {
color: #fff;
background-color: #3F8AE4;
border-bottom: 1px solid rgba(0,0,0,0.1);
padding: 10px 0;
}
.parallax {
background: url(../images/backgruond.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding: 150px 0;
}
JS :
// Y axis scroll speed
var velocity = 0.5;
function update(){
var pos = $(window).scrollTop();
$('.topSection').each(function() {
var $element = $(this);
// subtract some from the height b/c of the padding
var height = $element.height()-0;
$(this).css('background-position', '50%' + Math.round((height - pos) * velocity) + 'px');
});
};
$(window).bind('scroll', update);
나는 최신 크롬에 모두 잘 찾을 수 있습니다. 어떤 브라우저를 사용하고 있습니까? – 4dgaurav