我很难做这件事。 我有一个有12个按钮的登陆页面。当您单击按钮时,它会将您定向到一个页面,其中包含一个带有12个标尺的导航栏。 我已经制作了一部分将其设置为活动的代码。
<li><a href="..." class="active">
当加载了活动类的页面加载时,它应该滚动到它。导航栏是水平的。我试过滚动,但没有快乐。谢谢。
更新: 这是样本ss。
http://postimg.org/image/xtn1ljsnt/ 选项卡“项目5”必须显示在中间。就像
Item4 Item5 Item6
感谢
答案 0 :(得分:0)
我很难想象标记如果您只提供单个元素,但如果您修改它以适合您的场景,下面的示例应该足够了。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<style>
#foo {
margin-top: 1000px;
}
</style>
</head>
<body>
<div id="foo">Hello</div>
<script>
$(function () {
$('html, body').animate({
scrollTop: $("#foo").offset().top
}, 2000);
});
</script>
</body>
</html>