html - Create equal height two column with css -
i want create equal height 2 column, 2 column right following height column left.
@import url('http://getbootstrap.com/dist/css/bootstrap.css'); .left-side { background-color: green; height: auto; } .right-side-up { background-color: red; height:100px; //ignore value, if u have other way } .right-side-down{ background: blue; height: 80px; //ignore value, if u have other way }
you use javascript define equal height of left side , right side.
var leftside = document.queryselector('.left-side'); var rightside = document.queryselector('.right-side'); var hleftside = leftside.clientheight; var hrightside = rightside.clientheight; var maxh = math.max(hleftside, hrightside); leftside.style.height = maxh + 'px'; rightside.style.height = maxh + 'px';
.left-side { background-color: green; height: auto; } .right-side-up { background-color: red; height:100px; } .right-side-down{ background: blue; height: 80px; }
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/> <div class="row"> <div class="col-xs-9 left-side"> <p>sdfsdf</p> <p>sdfsdf</p> <p>sdfsdf</p> <p>sdfsdf</p> </div> <div class="row right-side"> <div class="col-xs-3 right-side-up"> asdfdf </div> <div class="col-xs-3 right-side-down"> asdfdf </div> </div> <!-- close row --> </div>
or can use flexbox too
.flexbox { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .left-side, .right-side { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .left-side { background-color: green; height: auto; } .right-side-up { background-color: red; height:100px; } .right-side-down{ background: blue; height: 80px; } .row.no-padding, .col-xs-3.no-padding, .col-xs-9.no-padding { padding-left: 0; padding-right: 0; }
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/> <div class="row no-padding flexbox"> <div class="col-xs-9 no-padding left-side"> <p>sdfsdf</p> <p>sdfsdf</p> <p>sdfsdf</p> <p>sdfsdf</p> </div> <div class="col-xs-3 no-padding right-side"> <div class="col-xs-12 right-side-up"> asdfdf </div> <div class="col-xs-12 right-side-down"> asdfdf </div> </div> <!-- close row --> </div>
Comments
Post a Comment