1

如何使页面在悬停时自动滚动到下拉按钮的底部?我希望页面底部与按钮底部相接,并且我不希望它滚动得非常快。我尝试了一些javascript,但它似乎不起作用。这是按钮。

http://jsfiddle.net/5gq9E/

这是HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link href="/styles.css" rel="stylesheet" type="text/css">

</head>

<body>
<div id='cssmenu'>
<ul>
<li class='has-sub last'  id="iefix"><a rel=nofollow href='#'><span>Choose a 
model</span></a>
  <ul>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Aria</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Rhyme</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Surround</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Sensation</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Thunderbolt</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC One S</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC One X</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Evo 4G</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Inspire 4G</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC MyTouch 4G</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Evo 4G LTE</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Evo Shift 4G</span></a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Evo Droid Incredible 2</span>  
</a></li>
     <li  id="iefix"><a rel=nofollow href='#'><span>HTC Windows Phone 8X</span></a>  
</li>
     <li class='last'  id="iefix"><a rel=nofollow href='#'><span>HTC One</span></a>
</li>
  </ul>
</li>
</ul>
</div>
</body>
</html>
4

1 回答 1

0
$('#choose').live('hover',function() {
  var postion =  $("#categories li:last-child").offset();
  var top1 =  postion.top;
  var left1 = postion.left;

 window.scrollTo(top1, left1);

});

你可以试试这个。#choose 表示“选择模型” - span 和 #categories 表示包含所有 li 的 ul。

于 2013-09-02T13:03:22.787 回答