Skip to content

Instantly share code, notes, and snippets.

@terenty-rezman
Created May 10, 2021 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terenty-rezman/3fcf775812cfc5a1ef45f3ee1daa90dc to your computer and use it in GitHub Desktop.
Save terenty-rezman/3fcf775812cfc5a1ef45f3ee1daa90dc to your computer and use it in GitHub Desktop.
css flex children with overflow and scroll on them
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>flex with scrolls</title>
<style>
html, body {
margin: 0;
height: 100%;
}
div {
box-sizing: border-box;
}
.ui {
display: flex;
flex-direction: column;
padding: 20px;
height: 100%;
background-color: ivory;
}
.top {
background-color: wheat;
margin-bottom: 20px;
}
.bottom {
flex: 1 1 auto;
background-color: lightgray;
display: flex;
min-height: 0px; /* IMPORTANT: you need this */
}
.bottom > div {
flex: 0 0 100px;
margin-right: 10px ;
}
.bottom > div:nth-of-type(1) {
background-color: violet;
}
.bottom > div:nth-of-type(2) {
background-color: rgb(130, 180, 238);
}
.bottom > div:nth-of-type(3) {
flex: 1 1 auto;
background-color: rgb(130, 238, 202);
display: flex;
flex-direction: column;
min-width: 0px; /* IMPORTANT: you need this */
}
.preview {
overflow: auto;
background-color: deeppink;
flex: 1 1;
}
.history {
overflow: auto;
background-color: rgb(149, 93, 202);
flex: 1 1;
}
.big-content {
width: 1000px;
height: 2000px;
color: black;
background-color: #ddd;
padding: 20px;
}
</style>
</head>
<body>
<div class="ui">
<div class="top">
<button>button</button>
</div>
<div class="bottom">
<div>1</div>
<div>2</div>
<div>
<div class="preview">
<div class="big-content">
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."
</div>
</div>
<div class="history">
<div class="big-content">
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment