To get min-height with relative units that work even in IE11, you only need a little trick.
The nature of min-height is to overwrite height when height less than min-height . Very clear! But the trap occurs when min-height has a real unit ( % or vh ), and height not set. Since it is relative, it has no reason to relay.
For all major browsers except Internet Explorer, one possibility is to change the unit of measure from % to vh :
body { min-height: 100vh; }
Internet Explorer requires height (will be overwritten from min-height ):
body { height: 1px; min-height: 100vh; }
or to save % rules must be applied to html :
html, body { height: 1px; min-height: 100%; }
The cross-browser solution for the OP requires height: 1px per body and, of course, flex-grow: 1 for .wrap to allow it to grow faster than menu and footer :
body, html { padding: 0; margin: 0; height: 1px; min-height: 100%; } body { display: flex; background: #eee; flex-direction: column; } .menu { background: red; color: #fff; padding: 10px; } .wrap { display: flex; flex-grow: 1; } .sidebar { background: #ddd; width: 300px; } .main { background: #ccc; flex: 1; } .footer { background: #000; color: #fff; padding: 10px; }
<div class="menu">Menu</div> <div class="wrap"> <div class="sidebar">Sidebar</div> <div class="main">Main</div> </div> <div class="footer">Footer</div>
kmgt
source share