html - Bootstrap image gallery grid align issue -
i trying build kind image grid using bootstrap have issue understanding how create code. here final example.
here code until
.border { border: 1px solid red; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <div class="container"> <div class="row"> <div class="col-md-4 border"> <img src="images/https://images-na.ssl-images-amazon.com/images/i/81eecpmxy7l._sx355_.jpg" width="360" height="243" title="sometext" alt="sometext"> </div> <div class="col-md-4 border"> <img src="images/https://images-na.ssl-images-amazon.com/images/i/81eecpmxy7l._sx355_.jpg" width="360" height="516" title="sometext" alt="sometext"> </div> <div class="col-md-4 border"> <img src="images/https://images-na.ssl-images-amazon.com/images/i/81eecpmxy7l._sx355_.jpg" width="360" height="243" title="sometext" alt="sometext"> </div> </div> <div class="row"> <div class="col-md-8 border"> <img src="images/https://images-na.ssl-images-amazon.com/images/i/81eecpmxy7l._sx355_.jpg" width="360" height="243" title="sometext" alt="sometext"> </div> <div class="col-md-4 border"> <img src="images/https://images-na.ssl-images-amazon.com/images/i/81eecpmxy7l._sx355_.jpg" width="360" height="243" title="sometext" alt="sometext"> </div> </div> </div><!-- container -->
what have row has 3 columns in it. 2 of 3 columns have 1 column have 2 rows.
here basic example can build off of.
.gallery .v-spacer { margin-top: 30px; /* default bootstrap gutter (10px) x 2 */ }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="row gallery"> <div class="col-sm-4"> <div class="row"> <div class="col-sm-12"> <img class="img-responsive" src="http://placehold.it/600x400/fc0/"> </div> </div> <div class="row v-spacer"> <div class="col-sm-12"> <img class="img-responsive" src="http://placehold.it/600x400"> </div> </div> </div> <div class="col-sm-4"> <img class="img-responsive" src="http://placehold.it/600x830"> </div> <div class="col-sm-4"> <div class="row"> <div class="col-sm-12"> <img class="img-responsive" src="http://placehold.it/600x400"> </div> </div> <div class="row v-spacer"> <div class="col-sm-12"> <img class="img-responsive" src="http://placehold.it/600x400/fc0/"> </div> </div> </div> </div>
notice continue use .row
, column classes .col-**-**
maintain proper structure of grid use padding , negative margins create gutters (space) between columns , containers.
edit you'll have bit of issue middle image if try make responsive. middle image not line stacked images. because total height of stacked image columns 2 variable heights plus fixed height. middle image won't able match 100% because it's single variable height , won't able match fixed height that's introduced in stacked columns.
Comments
Post a Comment