Reputation: 15930
I want to make a table with a cell that spans on two rows. The second row must have the height size as minimum as possible. Example:
html:
<table>
<tr id="row-1">
<td>
1st row
</td>
<td rowspan="2">
a <br />
a <br />
a <br />
a <br />
a <br />
a <br />
a <br />
a <br />
</td>
</tr>
<tr id="row-2">
<td>
2nd row
</td>
</tr>
</table>
css:
td
{
border: 1px solid black;
}
#row-2
{
height: 1px;
}
It works on Firefox (19.0.2). On Chromium (25.0.1364.160), the row with the minimum height is the first one!
EDIT: The problem is caused by this bug: http://code.google.com/p/chromium/issues/detail?id=78724
How can I hack it with CSS? Currently I'm using JS, setting the 1st row height equal to the height of the rowspan cell minus the height of the second row.
Upvotes: 1
Views: 7940
Reputation: 416
Answer from Lucas Malor almost works.
It happens that IE doesn't respect table height=100% :( For me solution was easy, I just set height in pixels, because I know height of first column.
Upvotes: 1
Reputation: 15930
Found: the trick is to put another table inside a cell of the table with the non-rowspan content, remove the rowspan from the other cell and set the outer and inner table height to 100%. Horrible but effective.
HTML:
<table id="outer"><tbody><tr>
<td>
<table id="inner"><tbody>
<tr id="row-1">
<td>1st row</td>
</tr>
<tr id="row-2">
<td>2nd row</td>
</tr>
</tbody></table>
</td>
<td>
a<br />
a<br />
a<br />
a<br />
a<br />
a<br />
a<br />
a<br />
a<br />
</td>
</tr></tbody></table>
CSS:
#row-2
{
height: 1px;
}
#outer, #inner
{
height:100%;
}
Upvotes: 3
Reputation: 3431
try position:fixed
it sort of works. http://jsfiddle.net/43CEX/
i think in general you want to use divs for this kind of work, since tables natively grow by their own
update
this http://jsfiddle.net/h4Ycj/
or this http://jsfiddle.net/m7eqm/
Upvotes: 0