Iframe in Internet Explorer Quirks mode will not render at 100% width

南笙酒味 提交于 2019-12-12 05:47:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!