2016-06-30 96 views
0

我想要我的链接在页面上水平滚动动画滚动到所需的“ID”,而不是跳到它。这是我迄今为止的,但它似乎并没有工作。自动滚动水平链接跳转

HTML:

<div class = option1> 
    <a href= #point1> ➟ </a> 
</div> 

<div id = point1></div> 
<!-- id point is not in the "body" of the link? does that matter? --> 

CSS:

body { 
    min-height:100%; 
    height:100%; 
    margin:0; 
    width:auto; 
} 

html { 
    min-height:100%; 
    height:100%; 
    overflow-y:hidden; 
    width:100% } 

的JavaScript:

$(document).ready({ 
    $(function() { 
    $('ul.nav a').bind('click',function(event){ 
     var $anchor = $(this); 
     $('html, body').stop().animate({ 
     scrollLeft: $($anchor.attr('href')).offset().left 
     }, 15000); 
     event.preventDefault(); 
    }); 
    }); 
}); 
+0

检查** **过渡的CSS属性。 – FDavidov

+0

是的我已经尝试过渡时间:5秒,但没有做任何事情 – sosro

回答

0

请尝试使用类= “名” 不CLA SS =名称

了明智这看起来类似: Smooth scrolling when clicking an anchor link

+0

啊好吧,谢谢我会有一个修补程序 – sosro

+0

@sosro:如果这是合适的答案,请将此答案标记为正确答案。 –