html - How can I make my flexbox layout take 100% vertical space? -


how can tell flexbox layout row consume remaining vertical space in browser window?

i have 3-row flexbox layout. first 2 rows fixed height, 3rd dynamic , grow full height of browser.

enter image description here

i have flexbox in row-3 creates set of columns. adjust elements within these columns need them understand full height of browser -- things background color , item alignments @ base. major layout resemble this:

enter image description here

.vwrapper {      display: flex;      flex-direction: column;      flex-wrap: nowrap;      justify-content: flex-start;      align-items: stretch;      align-content: stretch;      //height: 1000px;  }  .vwrapper #row1 {      background-color: red;  }  .vwrapper #row2 {      background-color: blue;  }  .vwrapper #row3 {      background-color: green;      flex 1 1 auto;      display: flex;  }  .vwrapper #row3 #col1 {      background-color: yellow;      flex 0 0 240px;  }  .vwrapper #row3 #col2 {      background-color: orange;      flex 1 1;  }  .vwrapper #row3 #col3 {      background-color: purple;      flex 0 0 240px;  }
<body>      <div class="vwrapper">          <div id="row1">              header          </div>          <div id="row2">              second line          </div>          <div id="row3">              <div id="col1">                  col1              </div>              <div id="col2">                  col2              </div>              <div id="col3">                  col3              </div>          </div>      </div>  </body>

i've tried adding height attribute, work when set hard number not when set 100%. understand height: 100% isn't working, because content isn't filling browser window, can replicate idea using flexbox layout?

you should set height html, body, .wrapper 100% (in order inherit valid value) , set flex value superior @ 1 .row3 , none others.

.wrapper, html, body {      height:100%;      margin:0;  }  .wrapper {      display: flex;      flex-direction: column;  }  #row1 {      background-color: red;  }  #row2 {      background-color: blue;  }  #row3 {      background-color: green;      flex:2;      display: flex;  }  #col1 {      background-color: yellow;      flex :0 0 240px;  }  #col2 {      background-color: orange;      flex: 1 1;  }  #col3 {      background-color: purple;      flex: 0 0 240px;  }
<div class="wrapper">      <div id="row1">this header</div>      <div id="row2">this second line</div>      <div id="row3">          <div id="col1">col1</div>          <div id="col2">col2</div>          <div id="col3">col3</div>      </div>  </div>

demo


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -