html - Using Bootstrap column classes with divs of varying heights -
i setting seemingly easy layout using bootstrap 3 8 text divs, same height taller others depending on screen width.
i'd them fit 3 columns on desktop , shrink 2 columns on smaller screens.
what i've tried
setting each div col-xs-6 , col-md-4. however, on desktop, size of div causing gaps in 'cells'.
wrapping each set of 3 divs in
.row
fixes problem on desktop adds new problem on mobile. (see code below)adding clearfix div visible-md not solve problem.
how can make following markup display in 3 columns on desktops , 2 columns (with no gaps) on mobile devices?
<div class="row"> <div class="col-xs-6 col-md-4"> <h4><a href="#bond">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#buffa">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#ebert">text text</a></h4> <p class="subtitle">managing director</p> </div> </div> <div class="row"> <div class="col-xs-6 col-md-4"> <h4><a href="#gale">text text</a></h4> <p class="subtitle">chief accounting officer</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#kleinman">text text</a></h4> <p class="subtitle">general counsel & managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#scarpati">text text</a></h4> <p class="subtitle">chief compliance officer</p> </div> </div> <div class="row"> <div class="col-xs-6 col-md-4"> <h4><a href="#selinger">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#tareke">text text text</a></h4> <p class="subtitle">managing director</p> </div> </div>
the row class used create groups of columns, isn't needed. can rid of acheive want.
html:
<div class="col-xs-6 col-md-4"> <h4><a href="#bond">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#buffa">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#ebert">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#gale">text text</a></h4> <p class="subtitle">chief accounting officer</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#kleinman">text text</a></h4> <p class="subtitle">general counsel & managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#scarpati">text text</a></h4> <p class="subtitle">chief compliance officer</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#selinger">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#tareke">text text text</a></h4> <p class="subtitle">managing director</p> </div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <div class="col-xs-6 col-md-4"> <h4><a href="#bond">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#buffa">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#ebert">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#gale">text text</a></h4> <p class="subtitle">chief accounting officer</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#kleinman">text text</a></h4> <p class="subtitle">general counsel & managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#scarpati">text text</a></h4> <p class="subtitle">chief compliance officer</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#selinger">text text</a></h4> <p class="subtitle">managing director</p> </div> <div class="col-xs-6 col-md-4"> <h4><a href="#tareke">text text text</a></h4> <p class="subtitle">managing director</p> </div>
Comments
Post a Comment