how to make auto scroll to the end in css
let objDiv = document.getElementById("divExample");
objDiv.scrollTop = objDiv.scrollHeight;
how to make auto scroll to the end in css
let objDiv = document.getElementById("divExample");
objDiv.scrollTop = objDiv.scrollHeight;
auto scroll a div
<style>
// NOTE: to auto scroll a div smoothly
#direct-chat-messages
{
scroll-behavior: smooth;
}
</style>
<script>
// NOTE: to auto scroll a div.
window.setTimeout(function() {
var elem = document.getElementById('direct-chat-messages');
elem.scrollTop = elem.scrollHeight;
}, 100);
</script>
css no overflow
div.ex1 {
overflow: scroll;
}
div.ex2 {
overflow: hidden;
}
div.ex3 {
overflow: auto;
}
div.ex4 {
overflow: visible;
}
js auto scroll in div
<style>
.scroll-text{
overflow-y: auto;
height: 61px;
width:auto;
}
</style>
<div class="scroll-text" id="data">
f
</div>
<script>
var my_time;
var count = 0;
setTimeout('pageScroll()', 1200);
function pageScroll() {
if (count < 2) {
var objDiv = document.getElementById("data");
objDiv.scrollTop = objDiv.scrollTop + 1;
if (objDiv.scrollTop == objDiv.scrollHeight - 61) {
setTimeout(function () {
objDiv.scrollTop = 0;
count++;
}, 1200);
}
my_time = setTimeout('pageScroll()', 30);
}
}
</script>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us