body 的宽度 100% ≠ 100% (仅 IE6)(转)

body 的宽度 100% ≠ 100% (仅 IE6)通常表现为 iframe 出现纵向滚动条时同时出现横向滚动条,

简单粗暴的使用body{overflow-x:hidden;}是不负责任的,有时会截断要显示的内容第一个页面(父页面)

<iframe frameborder="0" height="300" scrolling="auto" src="iframe.html" width="500">

 

第二个页面(iframe)

HTML

<div></div>

CSS

body, div{margin:0;padding:0;}div{background-color:yellow;height:500px;}

正常效果

 

IE6

解决方法

在iframe中html页面上设置body的style

body{_width:expression(this.parentNode.offsetHeight > this.parentNode.scrollHeight ? '100%' : parseInt(this.parentNode.clientWidth) + 'px');}
 

posted @ 2010-04-20 09:44  builderman  阅读(656)  评论(0编辑  收藏  举报