问题
I have an iframe which is absolutely poitioned at the top of a page. This is actually a header that is added to customer's webpages, as such DOCTYPEs will vary and thus so will the Document mode.
The iframe renders at 100% no problem in Standards mode, but will NOT in Quirksmode - instead around 90 or 95%, left aligned. Here is the HTML:
<iframe
src="http://localhost:8080/pagedetails/28/false"
id="su3-frame"
hspace="0" vspace="0"
leftmargin="0" rightmargin="0"
topmargin="0" marginwidth="0"
style="top: 0px;"
frameborder="0" >
</iframe>
and the css:
iframe#su3-frame {
width: 100%;
height: 60px;
border: 0;
margin: 0;
padding: 0;
position: absolute;
top: 0; left: 0;
z-index: 100000000;
}
Anyone seen this before? Any suggestions for stuff I could try?
Thanks
回答1:
Adding this CSS fixes it (in IE8/IE7 Quirks Mode):
html {
margin: 0;
padding: 0
}
It's surely safe to universally include that - I imagine virtually zero sites are relying on the <html> element having margin or padding.
Some sites apply a non-zero margin or padding to <body>, but never to <html>.
来源:https://stackoverflow.com/questions/5016105/iframe-in-internet-explorer-quirks-mode-will-not-render-at-100-width