css - Bootstrap 3 columns in one row same height -


i'm building webapp angularjs , bootstrap 3 , sass. want columns in row have same height. a bootply supplied.

the problem don't know size of subset in items array since comes server , size of subset effects height of column. therefore don't want use fixed height columns. solution should work multiple screen-sizes (col-xs col-lg) feel can handled purely css rather javascript hacking.

i ng-repeat on list looks this:

javascript:

  $scope.items = [{     name: 'one',     subset: [{name: 'one-one'}, {name: 'one-two'},{name: 'one-three'}]   }, {     name: 'two',     subset: [{name: 'two-one'}, {name: 'two-two'}]   }]; 

html:

<div class="row">   <div ng-repeat="item in items">     <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">       <div class="menu-item">         <div class="menu-item-header">           <span>{{item.name}}</span>         </div>         <div ng-repeat="subitem in item.subset">           <span>{{subitem.name}}</span>           </div>         <button class="btn btn-default">do something</button>         </div>       </div>    </div> </div> 

css:

.menu-item {   border: 1px solid black;   border-radius: 10px;   padding: 5px; }  .menu-item-header {   font-weight: bold;   text-align: center;   margin-bottom: 5px; } 

flexbox this, that's not supported.

your best bet fake it. instead of worrying getting columns same height, work element containing columns. default, expand accommodate child greatest height.

then, apply sneaky background image gives illusion of borders or background colours:

.row{     background: url(sneaky.png) repeat-y; } 

this trick has been around while: http://alistapart.com/article/fauxcolumns

update flexbox

using flexbox equal height columns trivial. apply flexbox parent:

<div class="row" style="display:flex;"> 

and.... you're done. children have same height added class called col each column div background colour , margin can tell equal height.

http://www.bootply.com/120891


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -