You create a Javascript like this:
function updateScroll() {
var element = document.getElementById("teste");
element.scrollTop = element.scrollHeight;
}
updateScroll();
var timerId = window.setInterval(1, 1000);
setTimeout(function () {
clearInterval(timerId)
}, 10000);
In CSS you don’t need to change anything, but you can use the following to hide the bar (but it will still work)
ul::-webkit-scrollbar{
display: none;
}
Just put an id in ul and put the name of that id in Javascript instead.
Link Jsfiddle
function updateScroll() {
var element = document.getElementById("teste");
element.scrollTop = element.scrollHeight;
}
updateScroll();
var timerId = window.setInterval(1, 1000);
setTimeout(function () {
clearInterval(timerId)
}, 10000);
ul {
list-style: none;
max-height:380px;
width:500px;
overflow-y:auto;
padding:5px;
background-color:#ccc;
position: absolute;
bottom:0;
}
ul>li {
height:80px;
margin-bottom:5px;
width:100%;
background-color:#888;
}
ul::-webkit-scrollbar{
display: none;
}
<ul id="teste">
<li>111111111111</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>222222sasa222222</li>
<li>222222222222</li>
<li>222222222222</li>
<li>22asa</li>
<li>222222sasa222222</li>
<li>222222sasa222222</li>
<li>222222sasa222222</li>
<li>222222sasa222222</li>
<li>222222sasa222222</li>
<li>FINAL</li>
</ul>
Do you need the read that represents a user’s message to be in the left margin of the current user with the right margin? Just like in Whatsapp? What kind of alignment exactly?
– Guilherme Nascimento
Hello @Guilhermenascimento ! What I need to do is just align the message blocks below, so that when the first chat message appears, it will appear below and then go up as new messages appear. As for the question of aligning the messages on the right and left, there is no problem.
– alexander Pataki
you want to
<li>222222222222</li>
appear above<li>111111111111</li>
?– Guilherme Nascimento