Forum Moderators: not2easy

Message Too Old, No Replies

Borders and margins disappearing in IE

Rendering bug?

         

grahamstewart

7:45 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yike - major problem...

I've just put my site online to show to my client.

Tested it plenty before I did so - looking good in Opera 7, IE6 and Netscape 7 - plus its all been validated as HTML 4.01 Strict and CSS compliant.

Put it online and I discover to my horror that some of the borders and margins disappear in IE 6. I have no idea why - its not always the same ones and they re-appear if you cause a re-draw by dragging another window over the top of the browser, so I guess its some kind of bug in the IE rendering engine.

Must be related to speed since I never saw any of this when I tested locally and now I'm seeing it all the time.

Any solutions? Please?

grahamstewart

8:54 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its definitely not the peek-a-boo bug - I've eliminated all the floats and it still happens.

My current theory is that it something to do with have lists of links for my nav menu.

Anyone got any thoughts?

Hester

8:57 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're using borders on divs then yes, it's an IE drawing bug. It's down to a timing issue that the engineers apparently are unwilling to fix because it would mess up the engine. Or the code is too fine to increase the timing.

I had to abandon a layout because of this.

grahamstewart

9:06 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Aaaaaaaaaargh.. not a good time to be hearing this.. :(

So what do I need to do? Slow down my page to make it work?

Avoid using any borders on any divs?
Or just the divs that contain lists?

Hester

9:45 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One or two borders seem to work fine. My layout had several small boxes. You can see a screenshot in the Archives section on my site. IE would randomly miss parts of the borders out. If you scrolled up and down, or switched to another window and back, the borders returned.

I'd advise either not using them or *gulp* using nested tables instead.

Not sure how you could slow the page down.

This problem doesn't occur offline though!

BlobFisk

9:50 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ouch! That is nasty.

If you really want to use the layout you could (and it hurts to type it!) you could reload the IE page using IE conditionals:


<!--[if ie]>
<script type="text/javascript">
document.refresh();
</script>
<![endif]-->

Put it at the end of your page and it's refresh and (hopefully) fix the drawing problem... But it's pretty awful a hack!

TheWhippinpost

10:04 am on Jun 25, 2003 (gmt 0)

10+ Year Member



I had a similar problem with a background-color rule applied to <h?> tags. The solution, which works but may or may not be appropriate in your situ, was simply to apply position: relative;

grahamstewart

10:11 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I stuck a


* {
position: relative;
}

..in at the top of the CSS for good measure...
...but didn't help. :(

BlobFisk: It may come to that!

marek

10:21 am on Jun 25, 2003 (gmt 0)

10+ Year Member



Defining an explicit width, either fixed or 100%, sometimes helps IE to render boxes porperly.

grahamstewart

10:27 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BlobFisk: tried the refresh script, got a 'Object does not support this method' error.

BlobFisk

10:33 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm - how about this:

<script type="text/javascript">
var pageURL = unescape(window.location.pathname);
window.location.href = pageURL;
</script>

grahamstewart

10:53 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sort of works.... but the continual reloading is a little annoying (might need to add a variable so it only does it once).

It doesn't always seem to solve the problem tho.

Grrr..Damn you Microsoft
I was going to have a nice celebratory night with a good bottle of wine.

BlobFisk

11:00 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Completely forgot about that - if I had two brains I'd be twice as thick, as the saying here goes!

How about a META refresh?

trismegisto

12:08 pm on Jun 25, 2003 (gmt 0)

10+ Year Member



Hi graham.

How about this? I couldn’t test it in IE6 for PC since i’m using a mac, but i tested in IE 5.2 (OK, i know there is a difference between IE for mac and for PC, but maybe it could work).


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fake Borders</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all">
html, body {
margin: 0px;
padding: 0px;
}

#your-div {
width: 16em;
height: 8em;
}
#border-top {
position: absolute;
width: 16em;
height: 1px;
top: 1px;
left: 1px;
background: red;
}
#border-bottom {
position: absolute;
width: 16em;
height: 1px;
top: 8em;
left: 1px;
background: red;
}
#border-left {
position: absolute;
width: 1px;
height: 8em;
top: 1px;
left: 1px;
background: red;
}

#border-right {
position: absolute;
width: 1px;
height: 8em;
top: 1px;
left: 16em;
background: red;
}
</style>
</head>

<body>
<div id="your-div">
<div id="border-top"></div>
<div id="border-bottom"></div>
<div id="border-left"></div>
<div id="border-right"></div>
</div>
</body>
</html>

It uses 1px absolute positioned divs to make the borders.

Hope it helps.

grahamstewart

12:33 pm on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks trismegisto - if I get very desperate I can always fake the borders using a background image (since most of them only appear on one side of the div).

But I'd rather avoid it - the site is very lean and mean at the moment - and I'd rather not re-code it and introduce more images to load.

Besides.... I shouldn't have too!

("Momma.. wheres my whippin' belt? Gonna teach that gates boy a lesson....")

TheWhippinpost

3:51 pm on Jun 25, 2003 (gmt 0)

10+ Year Member



("Momma.. wheres my whippin' belt? Gonna teach that gates boy a lesson....")

Dunno 'bout a belt, but you can strap him to my 'post' if ya like ;¬)

grahamstewart

5:59 pm on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm.. seems to have been some kind of dodgy bug in IE6.

SuzyUK and BlobFisk couldn't see it but I could so it may be because I was using Windows XP or it may indeed be a timing issue.

Not entirely certain of what was going on but it did seem to be related to absolute positioning, so I fixed it by recoding the layout to use normal flow rather than absolute positioning. :)

Many, many, many thanks to SuzyUK and BlobFisk who went above and beyond the call of duty to help me out.

DrDoc

12:41 am on Jun 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a bug very similar to the peek-a-boo bug...

Do you have any positioned elements? Add position:static to all unpositioned block-level elements.

bradc

1:16 am on Jun 26, 2003 (gmt 0)

10+ Year Member



I've found that IE6 offers NO improvements over IE5.5, and in fact it is a step backwards. The only thing it provides is that bloody awful (and totally useless) "personal bar". Everything else sucks, and although it is supposed to be W3C compliant, that doesn't make it any better.

Well that's my personal rant taken care of, now onto the problem.

Have you tried increasing the width of the borders? Getting tables right is pretty tricky because the tables are actually 6 layers deep, and I think it's possible that IE6 might be placing the layers on the page in an incorrect order when it *first* renders the page, then when the page is redrawn (by windows auto-redraw property) it's putting them back in the right place.

I'm just thinking maybe if you exaggerate the borders by making them massively bigger than you realistically need, you might be able to detect if this is happening.

Alternatively if there is some way to manipulate the transparency/opaqueness of the layers individually (I don't know yet) then you could experiment with this and see if it makes a difference.

I've racked my brains over it, and the only sensible answer for why this bug occurs seems to me to be the layers are being stacked incorrectly when the page is rendered.