DIV滚动条自动滚动到最底部的两种方法
查看原文方法1function updateScroll(){var element = document.getElementById("divId");element.scrollTop = element.scrollHeight;}方法2<div class="container"><div class="inner">Bottom</div><d
·
方法1
function updateScroll(){
var element = document.getElementById("divId");
element.scrollTop = element.scrollHeight;
}
方法2
<div class="container">
<div class="inner">Bottom</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Hi</div>
<div class="inner">Top</div>
</div>
<style>
.container {
height: 100px;
overflow: auto;
display: flex;
flex-direction: column-reverse;
}
</style>
更多推荐
所有评论(0)