现在,我使用一些 jquery 和缓动属性平滑滚动锚点。我希望能够使用箭头键滚动到每个部分。我怎样才能做到这一点?
HTML
<ul class="desktop">
<li><a href="#aboutus">ABOUT US </a></li>
<li><a href="#branding">BRANDING & IDENTITY</a></li>
<li><a href="#sponsorship">CAUSE MARKETING</a></li>
<li><a href="#promotion">EVENT MANAGEMENT</a></li>
</ul>
<div class="main-container" id="aboutus"></div>
<div class="main-container2" id="branding"></div>
<div class="main-container3" id="sponsorship"></div>
<div class="main-container4" id="promotion"></div>
JAVASCRIPT
<script src="js/jquery.easing.1.3.js"></script>
<script>
$(function() {
$('a').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500,'easeInOutExpo');
/*
if you don't want to use the easing effects:
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1000);
*/
event.preventDefault();
});
});
</script>