我用 jQuery
创建了一个 scrollTo
function
,它的效果非常好。
但是,当我在单击将 View 滚动到另一个 DIV
(div 滚动到 View 中)后刷新页面时,它不会返回到页面顶部(默认 View )。相反,它继续显示 DIV
View 。
我不知道是我的浏览器问题还是我的代码问题,如果代码对您有用,请告诉我!
HTML
<div class="banner">
<div class="arrow-down">
<div class="arrow">
</div>
</div>
</div>
CSS
.arrow-down {
width: 80px;
height: 80px;
left: 50%;
margin-left: -40px;
cursor: pointer;
z-index: 10;
bottom: 5%;
}
.arrow {
width: 24px;
height: 24px;
margin-left: -12px;
margin-top: -12px;
border-right: 3px solid white;
border-bottom: 3px solid white;
top: 50%;
left: 50%;
z-index: 20;
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow-down, .arrow {
position: absolute;
}
.test {
height: 1200px;
}
JavaScript/jQuery
$(document).ready(function() {
$('.arrow').click(function() {
$('html, body').animate({
scrollTop: $('.test').offset().top
}, 1000);
});
});
如果我不够清楚,请告诉我,我会尽力解答您的困惑。
最佳答案
这是由于谷歌浏览器默认标准保存您的持仓历史。而它会将您重定向到您所在的位置,就像书签一样。
这不是问题,只是浏览器功能问题,应该担心。
关于javascript - 正在刷新页面 - 在 DIV 处查看 "freeze"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35817671/