Use flexit tooflex-direction: column-reverse;
html, body {
margin: 0;
}
.wrapper {
display: flex;
flex-direction: column-reverse;
max-height: 100vh;
overflow: auto;
}
<div class="wrapper">
Top<br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Bottom
</div>
Run codeHide resultSide note:
, Firefox/Edge/IE11 ( , ), ,
, , .
var isWebkit = ('WebkitAppearance' in document.documentElement.style);
var isEdge = ('-ms-accelerator' in document.documentElement.style);
function updateScroll(el){
el.scrollTop = el.scrollHeight;
}
if (!isWebkit || isEdge) {
updateScroll(document.querySelector('.content'));
}
html, body {
margin:0;
}
.wrapper {
display: flex;
flex-direction: column-reverse;
max-height: 100vh;
overflow: auto;
}
.content { overflow: auto; }
@media screen and (-webkit-min-device-pixel-ratio:0) {
.content { overflow: visible; }
@supports (-ms-accelerator:true) { .content { overflow: auto; } }
}
<div class="wrapper">
<div class="content">
Top<br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Long content <br><br><br>
Bottom
</div>
</div>
Hide result