I'm working on a simple sidebar layout using flex:
html, body {
height: 100%;
width: 100%;
box-sizing: border-box;
font-size: 14px;
}
.wrapper {
width: 100%;
display: flex;
flex-direction: column;
}
.header {
display: flex;
justify-content: center;
background-color: grey;
padding: 10px;
}
.content {
display: flex;
flex-direction: row;
}
.sidebar {
display: flex;
flex-direction: column;
padding: 16px;
background-color: red;
overflow-y: scroll;
}
.pagedata {
display: flex;
padding: 16px;
flex-direction: column;
background-color: blue;
overflow: scroll;
}
<html>
<div class="wrapper">
<div class="header">
This is the header
</div>
<div class="content">
<div class="sidebar">
<div>SideBar:</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 1</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
<div>Option 2</div>
<div>Option 3</div>
<div>Option 4</div>
</div>
<div class="pagedata">
<p>Content Page</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
<p>This is the page data</p>
</div>
</div>
</div>
</html>
As it is the flex child's are not getting full heigh if screen height is bigger than content, and if screen height is smaller than content, the whole page is scrolling vertically.
How can I make the flex children scroll their own content using CSS:
sidebar
must scroll vertically (Y)pagedata
must scroll horizontally and vertically (X and Y)
Both of them I want to fill full height (even if content is smaller than height).