Reputation: 1910
I have this snippet:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body style='overflow: hidden;'>
<style>
*, :after, :before {
box-sizing: border-box;
}
.example {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;
max-height: 100%;
}
.bottom {
overflow: auto;
height: 140px;
max-height: 100%;
flex-shrink: 0;
white-space: pre-wrap;
}
.top {
position: relative;
display: flex;
}
.scroll {
overflow-y: scroll;
width: 100%;
}
.elements {
position: relative;
}
.test {
margin-top: 20px;
}
</style>
<article class="example">
<div class="top">
<div class="scroll">
<article class="elements">
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
</article>
</div>
</div>
<article class="bottom">
Bottom
</article>
</article>
</body>
</html>
Upvotes: 1
Views: 825
Reputation: 13558
Bit changes to your code
*,
:after,
:before {
box-sizing: border-box;
}
/* some normalization to document */
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.example {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;
max-height: 100%;
}
.bottom {
overflow: auto;
height: 140px;
max-height: 100%;
flex-shrink: 0;
white-space: pre-wrap;
}
/* handling overflow here */
.top {
position: relative;
display: flex;
overflow: auto;
}
/* removed overflow here */
.scroll {
width: 100%;
}
.elements {
position: relative;
}
.test {
margin-top: 20px;
}
<article class="example">
<div class="top">
<div class="scroll">
<article class="elements">
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
<article class="test">
TEST
</article>
</article>
</div>
</div>
<article class="bottom">
Bottom
</article>
</article>
Upvotes: 0
Reputation: 4147
You don't have a height set for the article container ( and you can use overflow: auto; too ).
.elements {
position: relative;
overflow: auto;
height: 150px;
}
Upvotes: 1