Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save backcountrymountains/2778f7bd88140704f22a6d7d190c54b5 to your computer and use it in GitHub Desktop.
Save backcountrymountains/2778f7bd88140704f22a6d7d190c54b5 to your computer and use it in GitHub Desktop.
Autoscrollable element
<div class="container">
<div class="autoscrollable-wrapper">
<div class="autoscrollable-content" />
</div>
</div>
function randomString() {
return (Math.random() + 1).toString(36).substring(7);
}
const autoscrollable = document.querySelector('.autoscrollable-content');
setInterval(() => {
const element = document.createElement('div');
element.append(`some random string: ${randomString()}`);
autoscrollable.append(element);
}, 300);
.container {
height: 150px;
width: 200px;
color: #001f3f;
background: #3D9970;
padding: 5px;
}
.autoscrollable-wrapper {
overflow: scroll;
max-height: 100%;
display: flex;
flex-direction: column-reverse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment