为你定位<div>
的是用CSS绝对定位,你可以了解更多关于in this guide最简单的方法。这是最一致显示的跨浏览器和将让您对其中集装箱被放置细粒度的控制:
<ul id="nav">
<li><a href="#first">First</a></li>
<li><a href="#second">Second</a></li>
<li><a href="#third">Third</a></li>
</ul>
<div id="first">First content container</div>
<div id="second">Second content container</div>
<div id="third">Third content container</div>
有了大致如下CSS:
ul {
position: fixed;
z-index: 2;
top: 20px;
right: 20px;
}
div {
position: absolute;
z-index: 1;
width: 100px;
height: 100px;
}
#first {
top: 10px;
left: 10px;
}
#second {
top: 1000px;
left: 500px;
}
#third {
top: 500px;
left: 100px;
}
然后实际滚动到上点击不同的<div>
的,你可以使用jQuery scrollTo plugin:
$('a').click(function(e) {
// Stop default link click from occuring
e.preventDefault();
// Scroll to the position using the jQuery scrollTo plugin
// Element id is taken from link's href attribute
$(window).scrollTo($(this).attr('href'), {duration: 500});
});
你可以看到一个简单的例子in action here。
来源
2010-08-29 18:04:44
Pat
你的问题是什么? – 2010-08-29 17:41:02