views:

1568

answers:

2

I use tables for generating simple horizontal graphs (for easy scaling). I use colspanning to get exact overlapping (sometimes the cells overlap each other, but not in this example).

My issue is that IE(8) renders the relative cell widths wrong.

I know that a cell can not get smaller than it's content, but that is not the issue here.

For example the "X 65" cell in the example gets alot wider then 47% in IE. Firefox is doing great however.

Here is the example:

<html>
<body>

<style>
table.CompAnalysisTable {
    border-width: 1px;
    border-spacing: 0px;
    border-style: solid;
    border-color: black;
    border-collapse: collapse;
    background-color: white;
    font-size:8px;
}

table.CompAnalysisTable td {
    border-width: 1px;
    border-style: solid;
    border-color: black;
}

table.CompAnalysisTable td table 
{
    border-style:none;
}
</style>

<table>
<tr>
<td>
</td>
<td class="nobr" valign="middle" align="left">Graph</td>
<td valign="middle" width="100%" align="right">Total 73</td>
</tr>
</tbody>
</table>

<table class="CompAnalysisTable" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="nobr" style="width: 47%; background-color: rgb(172, 172, 255);" colspan="65">X&nbsp;65</td>
<td class="nobr" style="width: 47%; background-color: white;" colspan="65"></td>
<td class="nobr" style="width: 5%; background-color: rgb(172, 172, 255);" colspan="7">A&nbsp;7</td>
<td class="nobr" style="width: 1%; background-color: rgb(172, 172, 255);">B&nbsp;1</td>
</tr>
<tr>
<td class="nobr" style="width: 47%; background-color: white;" colspan="65"></td>
<td class="nobr" style="width: 52%; background-color: rgb(255, 152, 152);" colspan="72">A&nbsp;72</td>
<td class="nobr" style="width: 1%; background-color: rgb(255, 152, 152);">B&nbsp;1</td>
</tr>
</table>


</body>
</html>

I have tried other techniques like divs and separate tables for each row, but colspanning has been the only technique for getting the overlapping exact.

Another solution is to render images on the server, but then i loose the scaling and it is pretty time consuming.

Any help is much appreciated.

A: 

A header like this will save you the trouble of fixing it for IE 8 by having it render it as IE 7:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Other than that you can try to see what it is that IE 8 is doing and fix that with a specific html condition:

<!--[if IE 8]><![endif]-->

I wish I could help more, but I do not have IE 8 so I cannot see the problem.
Maybe these links can help:

HTML conditions
Beyond Doctypes

Tom
A: 

I had the same problem than you ... My solution is to use some funky javascript (with Jquery of course ;-) ) code to fix the TD widths ...

Something useless as well, if you want a width to 100%, set its width to 10 000px !

Same problem on IE, Google Chrome & Safari

eBuildy