I have 2 divs (6 columns each). In the div on the left is the image, in the div on the right is some kind of quote. I want my right div height to be the same as the image height.
Here is my code: http://codepen.io/matysflance/pen/PZXdBK
<div id="testimonials" class="container-fluid testimonials"> <div class="row"> <div class="col-lg-6 image"> <img src="http://placehold.it/1100x700/f3e42a" alt=""> </div> <div class="col-lg-6 quote"> <blockquote> <p>"Integer posuere erat a ante venenatis dapibus posuere veit al..." </p> <cite>Susan Sims, Interaction Designer at XYZ</cite> </blockquote> </div> </div> </div>
You can make a container of both divs flexbox that will automatically apply equal heights to child elements.
Try the following:
.row { display: flex; }
Revised Codepen
.row flex, (.image .quote) . . : fooobar.com/questions/5651/...
.row
.image
.quote
, jQuery
same-height DIV,
same-height
JQuery
jQuery(document).ready(function($) { //noconflict wrapper var heights = $(".same-height").map(function() { return $(this).height(); }).get(), maxHeight = Math.max.apply(null, heights); $(".same-height").height(maxHeight); });
jQuery Java Script. , . $( ".col-lg-6 quote" ).height($( ".col-lg-6 image" ).height())
$( ".col-lg-6 quote" ).height($( ".col-lg-6 image" ).height())
, .
:
var heightImgDiv = $('.ImgDiv').height(); $('.Div').height(heightImgDiv );
div { background: red; float: left; width: 250px; margin: 0 10px 0 10px; } img { display: block; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="ImgDiv"><img src="https://fallbacks.carbonads.com/nosvn/fallbacks/4cd1acdff7348a672d30bb3326800d80.jpeg"/></div> <div class="Div"></div>
.
Flexbox
flexbox :
.row { display: flex; /* equal height of the children */ } .col { flex: 1; /* additionally, equal width */ padding: 1em; border: solid; }
<div class="row"> <div class="col">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</div> <div class="col">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad omnis quae expedita ipsum nobis praesentium velit animi minus amet perspiciatis laboriosam similique debitis iste ratione nemo ea at corporis aliquam.</div> </div>
If you still need to support IE 8 or 9, you need to use a table:
.row { display: table; } .col { display: table-cell; width: 50%; /* depends on the number of columns */ padding: 1em; border: solid; }
Source: https://habr.com/ru/post/1628328/More articles:Showing hidden animation toolbar is not smooth - androidDynamically creating python class from protobuf file at runtime? - pythonSpark SQL performance difference in spark-sql versus spark-shell REPL - apache-sparkВключить внешний модуль requirejs - javascriptPromises in ES6 classes - javascriptНе удается перейти к маршруту, который имеет redirectTo, указанный в Angular2 по имени - angularUnable to connect to MS-SQL with ISQL - odbcGet ripple effect in RecyclerView with elements containing a different background color - androidLink routing in Angular2 - angular2-routingNSCollectionView OSX Cocoa Multiple Selection - objective-cAll Articles