Flexbox. Avoid Child With Longer Height Than Parent (column Direction)
I'm scaffolding a basic UI for a site using flexbox. Quite similar to the usual email layout. For some reason the second children( class .main-body, lightseagreen color) of a colum
Solution 1:
Flexbox introduces auto
as the new initial value of min-height
. It makes flex items grow as tall as their contents.
You can undo that by setting min-height
to 0
, the old initial value:
.content-main {
min-height: 0;
}
html,
body {
width: 100%;
height: 100%;
background: lightblue;
box-sizing: border-box;
}
* {
box-sizing: border-box;
}
.container {
height: inherit;
background: PeachPuff;
padding: 1em;
display: flex;
max-height: 500px;
}
.sidebar {
flex: 0115%;
background: khaki;
}
.content {
flex: 11 auto;
background: plum;
padding: 0.8em;
display: flex;
flex-direction: column;
}
.content-header {
background: lightgreen;
padding: 0.3em;
flex: 007%;
}
.content-main {
display: flex;
background: darkseagreen;
padding: 1em;
height: 100%;
flex: 11 auto;
min-height: 0;
}
.main-list {
flex: 0012%;
background: lightcoral;
}
.main-body {
flex: 01 auto;
padding: 1em;
background: lightcyan;
display: flex;
flex-flow: row wrap;
overflow-y: scroll;
}
<divclass='container'><divclass='sidebar'><ul><li>Onnnne</li><li>Twoo</li><li>Threee</li></ul></div><divclass='content'><divclass='content-header'><span>This iscontent header</span></div><divclass='content-main'><divclass='main-list'><ul><li>List 1</li><li>List 2</li><li>List 3</li></ul></div><divclass='main-body'><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div><divclass='panel'><table><thead><th>First</th><th>Second</th><th>Third</th><th>Third</th><th>Third</th><th>Third</th></thead><tbody><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr></tbody></table></div></div></div></div></div>
Post a Comment for "Flexbox. Avoid Child With Longer Height Than Parent (column Direction)"