Heey大家,中心DIV水平scolling
我建立這個水平滾動的網站,但是當我點擊從導航欄的鏈接上,在div出現在屏幕的右側,而不是在中心。有誰知道如何解決這一問題?
這裏是jQuery代碼我用:
$(function() {
$('.fixed-nav-bar li, .fixed-nav-bar a').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1500,'easeInOutExpo');
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1000);
event.preventDefault();
});
提前感謝!
我們可以通過jsFiddle和HTML以及CSS看到問題嗎? – Nitesh
此外,jQuery建議使用.on(),因爲jQuery 1.7+以上的.bind()http://api.jquery.com/on/ – Mortaza