views:

31

answers:

1

I encountered a table border line CSS problem in firefox, when the css border-collapse is collapse, and have 2 merged cells, one of them hava 1px border. A extra unwanted border line exsits on the right. This Problem does not exsits in other browsers, IE and Chrome don't have the problem.

FireFox version is

Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)

My tested doctype is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

.


alt text

<table cellspacing="0" cellpadding="0" style="position: absolute; width: 217px; left: 0px;border-collapse:collapse">
<colgroup><col col="0" style="width: 72px;"><col col="1" style="width: 72px;"><col col="2" style="width: 72px;">
</colgroup>
<tbody>
<tr tridx="0" style="height: 19px;">
<td rowspan="2" colspan="2" style="border: 1px solid #000000"></td><td row="0" col="2"></td>
</tr>
<tr tridx="1" style="height: 19px;"><td row="1" col="2"></td></tr>
<tr tridx="2" style="height: 19px;"><td row="2" col="0"></td><td row="2" col="1"></td><td row="2" col="2"></td></tr>
<tr tridx="3" style="height: 19px;"><td rowspan="3" colspan="2" style="border: 1px solid #000000"></td><td></td></tr>
<tr tridx="4" style="height: 19px;"><td ></td></tr>
<tr tridx="5" style="height: 19px;"><td></td></tr>
</tbody>
</table>
A: 

I don't know if there is a better fix for it, but the problem lies with colspan and the use of border-collapse.

I re-wrote the code just because it looked messy to me, but basically the solution was to use border-spacing: 0; instead of border-collapse: collapse;

This isn't perfect because they aren't the same thing. So if all of your cells had borders on them then the ones inside the table would double up creating a 2px border.

However in that situation you wouldn't notice anything and you could use border-collapse anyway.

Well, I think I have said enough.

Here is my code (A little different from yours but it does the same thing):

CSS:

<style type="text/css">
.tableStyle {
 position: absolute;
 left: 0px;
 border-spacing: 0;
}
.tableStyle td {
 height: 19px;
 width: 72px;
}
.blackBorder {
 border: 1px solid #000;
}
</style>

HTML:

<table class="tableStyle">
 <tr>
  <td rowspan="2" colspan="2" class="blackBorder">1</td>
  <td>2</td>
 </tr>
 <tr>
  <td>3</td>
 </tr>
 <tr>
  <td>4</td>
  <td>5</td>
  <td>6</td>
 </tr>
 <tr>
  <td rowspan="3" colspan="2" class="blackBorder">7</td>
  <td>8</td>
 </tr>
 <tr>
  <td>9</td>
 </tr>
 <tr>
  <td>10</td>
 </tr>
</table>
Sour Lemon
Thank you for your clear explanations and good advice. In fact, not all of my cells had borders on them, but some of them, it depends.If I use "border-collapse: collapse", table would double up creating 2px borders, else other cells without borders would had extra unwanted borders.
Fisher