css - Flexbox body and main min-height -


https://jsfiddle.net/vz7clmxy/

i'm trying have body expand min-height not work. i've read other related topics can't head around it.

html inside body

<div class="menu">menu</div>  <div class="wrap">     <div class="sidebar">sidebar</div>     <div class="main">main</div> </div>  <div class="footer">footer</div> 

css

body, html {     padding: 0;     margin: 0;     min-height: 100%; }  body {     display: flex;     background: #eee;     flex-direction: column; }  .menu {     background: red;     color: #fff;     padding: 10px; } .wrap {     display: flex; } .sidebar {     background: #ddd;     width: 300px; } .main {     background: #ccc;     flex: 1; } .footer {     background: #000;     color: #fff;     padding: 10px; } 

expected result main streched fill height if it's less 100%.

use flex: 1 on centered element:

.site {    display: flex;    min-height: 100vh;    flex-direction: column;  }    .site-content {    flex: 1;    background-color:#bbb;  }
<body class="site">    <header>this header text ☺</header>    <main class="site-content">…</main>    <footer>this footer text ☻</footer>  </body>


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -