background-attachmentを使わない背景固定でのスクロール

// pallarax
jQuery(function($){
var $window = $(window);

$('.fixed-bg').each(function(index) {
var $self = $(this);
var offsetPositions = $self.offset();

$(window).scroll(function() {
if (($window.scrollTop() + $window.height()) > offsetPositions.top && ((offsetPositions.top + $self.height()) > $window.scrollTop())) {
var offsetY = -($window.scrollTop() /100);
//if ($self.attr('class') != 'intro') {
// offsetY += 126;
// }
var positions = '50%' + offsetY + 'px';
$self.css('backgroundPosition', positions);
}
});
});
});

共有
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Posts published: 45
Copyrights © idew. All Rights Reserved.