Discussion Locked

iframe padding/margin bug..please help

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi all, i'm using iframe and regretting it. i can't eliminate the internal padding within the iframe, (i want the framed page to fill up the frame). i'm aware that there are some bugs with ie6 that cause padding and margin problems, but haven't found the definitive solution. i have messed around with style attributes and everything. please help...

thanks, gwen

2 replies

by roborubik

I have also run into this bug in IE6.

This problem only seems to show up when both the page containing the iFrame and the page in the iFrame have a DTD that switches IE6 into "standards complient mode".

If both pages have this DTD, and the iFrame has a CSS border, then extra space appears on the right and bottom sides between the contained page content and the iFrame's border. If either pages DTD is removed, then the iFrame works as you would expect.

The space appears to belong to the contained page. If the iFrame attributes are set to: allowtransparency=true & style="background:pink;"
then the space will appear pink. Adding a CSS margin to the contained page's html tag will add to the space, but setting it to 0px does not get rid of it. The width of the space grows and shrinks with the thickness of the CSS border applied to the iFrame and disapears when if the border is set to 0px.

I can't find any reference to this issue anywhere except for this post. I would like to report the bug to Microsoft, but do not know how.

Solutions:

Option 1: Remove the DTD from either document. Drawback is that this will put you back into "quirks mode" so the styles will have to be reworked. Also, the page will not validate (at least in the case of xhtml 1.0 Transitional).

Option 2: Remove the CSS border from the iFrame and add it to the html element of the page inside the iFrame. Like so:

I believe this problem has something to do with the "canvas moving" when IE6 switches into standards mode. It shifts the root of the pages display area to the html tag instead of the body tag. See this article on MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie60/html/cssenhancements.asp

** If anyone knows of a way to fix this with a style declaration on the iFrame, please post, because it would be a better solution.

This discussion is closed to new replies.