DIV滚动条自动滚动到最底部的两种方法

查看原文

方法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>
上一篇:迭代器


下一篇:iptables