Reputation: 6783
Please go through this fiddle to see what I have tried so far.
<div class="outer">
<div class="inner">
<table style="background-color: red; width:100%; height:100%;">
<tr style="background-color: red; width:100%; min-height:30%;">
<td>Name</td>
</tr>
<tr style="background-color: blue; width:100%; min-height:30%;">
<td>Nirman</td>
</tr>
<tr style="background-color: blue; width:100%; min-height:30%;">
<td>Nirman</td>
</tr>
</table>
</div>
</div>
I need to display this table occupying full height of the div, and rows of this table should be equal in height to occupy space of full table. That means, table's height should be 100% of div's height. and each row's height should be 30% of div's height.
Any idea of how to achieve this? Also, I would like a solution that should work on most of the browsers, at least, starting from IE 8.
Any help on this much appreciated.
Upvotes: 4
Views: 48645
Reputation: 2291
*{
margin:0;
padding:0;
border:0;
}
table{
height:100%;
position:absolute;
}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000"> </td>
</tr>
<tr>
<td bgcolor="#00FF00"> </td>
</tr>
<tr>
<td bgcolor="#0000FF"> </td>
</tr>
</table>
Here's a fiddle!
Upvotes: 1
Reputation: 105873
Through CSS , you have to set height of .inner . min-height value cannot be inherited : http://codepen.io/anon/pen/yuEkA a short cut would be :
html, body , .outer, .inner {
height:100%;
width:100%;
margin:0;
}
Upvotes: 3
Reputation: 188
In styles of the inner
div class, change min-height:100%
to height:100%
.
That's all you need!
(This is because min-height
can not be inherited)
Here's the jsfiddle
Upvotes: 7
Reputation: 847
jQuery solution for making 30% tr
height
var t_h = $('.inner').height()
var tr_h = t_h/100*30
$('tr').height(tr_h)
$('table').height(t_h);
Upvotes: -3
Reputation: 123
You can position the table absolute. For example, give it the class "full-height", and then add the following css:
table.full-height {
position: absolute;
bottom: 0;
top: 0;
left: 0;
right: 0;
}
This will expand the table to the full height!
Upvotes: 1