html - Not sure why flex-grow: 1 isn't working in my column layout -


i trying have views-cntnr take space not used views-cntnr , menubar divs. achieve this, have flex display set column direction. set flex-grow property views-cntnr 1. doesn't appear doing anything. jsfiddle

note: not sure if matters have nested flex displays going on.

html

<script src="https://code.jquery.com/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <script src="https://code.jquery.com/jquery-1.11.3.js"></script> <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>  <section class="analysis">   <div class="menubar">     <div class="view-ctrls text-center">       <div class="btn-group" role="group">         <button class="btn btn-default" ng-class="{'active-view': active_views[0]}" ng-click="toggleview(0)">r-theta</button>         <button class="btn btn-default" ng-class="{'active-view': active_views[1]}" ng-click="toggleview(1)">cartesian</button>         <button class="btn btn-default" ng-class="{'active-view': active_views[2]}" ng-click="toggleview(2)">longitudinal</button>         <button class="btn btn-default" ng-class="{'active-view': active_views[3]}" ng-click="">console</button>       </div>     </div>   </div>   <div id="views-cntnr">     <div class="r1">       <div id="v1" class="view">v1</div>       <div id="v2" class="view">v2</div>       <div id="v3" class="view">v3</div>     </div>     <div class="r2">       <div id="v4" class="view">v4</div>     </div>   </div>   <div id="frame-ctrl-cntnr">     <div id="frame-num" class="frame-ctrl"># x</div>     <div id="frame-range-cntnr" class="frame-ctrl">       <input type="range">     </div>   </div> </section> 

css

.analysis {   display: flex;   flex-direction: column; }   /* menubar */  .menubar {   padding: 4px 0 4px;   background-color: #eee; }   /* menubar */   /* views */  #views-cntnr {   display: flex;   flex-direction: column;   flex-grow: 1; }   /* row 1 */  .r1 {   display: flex; }  .r1 .view {   flex-grow: 1;   border: black 1px solid;   border-right: none; }  .r1 .view:last-child {   border-right: black 1px solid; } /* row 1 */  /* row 2 */ .r2 .view {   border: black 1px solid;   border-top: none; }   /* row 2 */   /* views */   /* frame ctrl */  #frame-ctrl-cntnr {   display: flex; }  .frame-ctrl {   border: black 1px solid;   border-top: none;   border-right: none; }  .frame-ctrl:last-child {   border-right: black 1px solid; }  #frame-num {  width: 50px; }  #frame-range-cntnr {   flex-grow: 1;   padding: 4px; }  /* frame ctrl */ 

everything in code working fine.

the issue your flex container has no specified height. therefore, height resolves auto, meaning height of content.

with no space in container, flex-grow has nothing do.

try adjustment css:

html, body { height: 100%; }  .analysis {     display: flex;     flex-direction: column;     height: 100%;     border: 1px dashed black; } 

we're telling flex container height of viewport. height of container taller height of content, , notice flex-grow doing work.

revised fiddle


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -