A Pen by Alberto Iannaccone on CodePen.
Created
August 9, 2024 16:22
-
-
Save backcountrymountains/2778f7bd88140704f22a6d7d190c54b5 to your computer and use it in GitHub Desktop.
Autoscrollable element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="autoscrollable-wrapper"> | |
<div class="autoscrollable-content" /> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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