Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个大 div,里面有文字:
#big-div { height: 400px; overflow: auto; }
我怎样才能使它在新内容添加到 div 时(并且发生溢出),div 自动滚动到底部。换言之,最新添加的内容始终可见。终端仿真器具有相同的行为。
您需要使用 JavaScript 强制它。
var myDiv = document.getElementById("big-div"); myDiv.scrollTop = myDiv.scrollHeight;