-2

i created 3 divs , i have to set equal height of all i tried with height:100% but its not working.all of these div have variation on them content but i need equal height of all.please help me!

<html>

<style type="text/css">

.b1{height:190px;width:150px;background:#963;float:left}
.b2{height:150px;width:150px;background:#955;float:left}
.b3{height:180px;width:150px;background:#966;float:left}

</style>
</head>

<body>

<div class="b1"></div>
<div class="b2"></div>
<div class="b3"></div>

</body>
</html>
Yajuvendra
  • 23
  • 5

4 Answers4

3

You need to set all parent elements height to 100%, in your case it will be:

body,html { height: 100%; }

Demo: http://jsfiddle.net/Cb4nU/3/

Peter
  • 16,453
  • 8
  • 51
  • 77
2

put this code in your css. i think this will help you..

 .b2{
    margin: 1px;
    background-color: ; 
    height: 100px;
    width:100px; 
    border: 1px solid ;
}
 .b2 {
    margin: 1px;
    background-color: ; 
    height: 100px;
    width:100px; 
    border: 1px solid ;
    }
 .b3 {
    margin: 1px;
    background-color: ; 
    height: 100px;
    width:100px; 
    border: 1px solid ;
}  

cheers...!

ѕтƒ
  • 3,547
  • 10
  • 47
  • 78
0

Wraping all 3 in a div with the height you want them to stretch to also works http://jsfiddle.net/Cb4nU/2/

<div class="a">
<div class="b1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nunc massa, accumsan ut volutpat id, gravida porta turpis. Duis tincidunt feugiat est nec rhoncus.    </div>
<div class="b2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nunc massa,</div>
<div class="b3">Lorem ipsum dolor sit amet</div>
</div>


.a{height:300px;}
.b1{height:100%;width:150px;background:#963;float:left}
.b2{height:100%;width:150px;background:#955;float:left}
.b3{height:100%;width:150px;background:#966;float:left}
Jess
  • 496
  • 5
  • 10
0

Hi below code snippet will do the needful,

CSS:

.parent { display:table; }
.b1{ border:1px solid red; display:table-cell; width:150px;background:#963;}
.b2{ border:1px solid green; display:table-cell; height:150px;width:150px;background:#955;}
.b3{ border:1px solid blue; display:table-cell; width:150px;background:#966;}

HTML

<div class="parent">
<div class="b1"></div>
<div class="b2"></div>
<div class="b3"></div>
</div>

Changes :

  1. Added parent container div
  2. Removed height & float:left property from all div's in css
  3. Added display property for all div's in css
Aratidgr8
  • 431
  • 4
  • 11