I have a <div>
on a page which is initially hidden with a visibility: hidden; position: absolute
. The issue is that if a <div>
hidden this way contains a table which uses border-collapse: collapse
and has a border set on it cells, that border still shows "through" the hidden <div>
on IE.
Try this for yourself by running the code below on IE6 or IE7. You should get a white page, but instead you will see:
alt text http://img.skitch.com/20090110-enuxpb5aduqceush46dyuf4wk7.png
Since this is happening on IE and not on other browsers, I assume that this is an IE bug. One workaround is to add the following code which will override the border:
.hide table tr td {
border: none;
}
I am wondering:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
/* Style for tables */
.table tr td {
border: 1px solid gray;
}
.table {
border-collapse: collapse;
}
/* Class used to hide a section */
.hide {
visibility: hidden;
position: absolute;
}
</style>
</head>
<body>
<div class="hide">
<table class="table">
<tr>
<td>Gaga</td>
</tr>
</table>
</div>
</body>
</html>
The solution I found consists in adding a top/left to move the rendering off-screen, which shields us against IE bugs of this sort. In the above example, this means that you would define the CSS for the hide
class as:
.hide {
visibility: hidden;
position: absolute;
top: -10000px;
left: -10000px;
}
More on: Workaround for table borders showing through on IE
This is a IE bug. Firefox doesn't recognize "border-collapse" using "border-spacing" instead which does not cause this problem. The solution of using "display:none" works, but there's another possibility. If the visibility property is set using Javascript then the border is hidden as well (as expected).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With