IE 5.x/Win 和模型bug

时间:2021-05-28

IEbug body .wrap{ width:500px;} .wrap *{text-align:left;} .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-table;} .clearfix {height: 1%;} .clearfix {display: block;} .clear{ clear:both;} #bug1{} .bugTitle{ position:absolute; left:0px; top:0px; width:100px; font:18px "Courier New", Courier, monospace; font-weight:bold;padding:5px; background:#f5f5f5;} #boxbug{ width:500px;width :530px; border:10px #f60 solid; margin:10px auto; padding:10px;} #boxbugie6{ width:500px; border:10px #f60 solid; margin:10px auto; padding:10px;} html>body #boxbugie6{ width:500px;} html>body #boxbug{ width:500px;} #bug2{} #ie3px,#ieno3px{float: left; width: 100px; height: auto; min-height:50px; background: #f60;} p.ie3px,p.no3px{margin: 0 0 0 100px; background: #333; text-align:left; color:#fff;} * html #ieno3px{margin-right:-3px;} * html p.no3px{height:1%;margin-left: 0;} #bug3{} #box1,#box2{ margin-left:50px; float:left; background:#f60; width:200px;} #box2{ display:inline ;} --> IE 5.x/Win 和模型bug 这里是一个width:500px;margin:10px;padding:10px; border:10px;的一个盒子.使用widht(空格):530px,解决IE5.x系列的盒解析bug,因为IE5.x系列浏览器能读到这句.在IE5.x Win,IE6.0 Win下效果一致.如何使用hack解决IE5.x盒解析bug? #content { width:530px; //这个是错误的width,所有浏览器都读到了 voice-family: "\"}\""; //IE5.X/win忽略了"\"}\""后的内容 voice-family:inherit; width:500px; //包括IE6/win在内的部分浏览器读到这句,新的数值(300px)覆盖掉了旧的 } html>body #content { //html>body是CSS2的写法 width:500px; //支持CSS2该写法的浏览器有幸读到了这一句,IE 5.x不支持的。 } #content { width:500px !important; //这个是正确的width,大部分支持!important标记的浏览器使用这里的数值 width(空格):530px; //IE6/win不解析这句,所以IE6/win仍然认为width的值是300px;而IE5.X/win读到这句,新的数值(400px)覆盖掉了旧的,因为!important标记对他们不起作用 } html>body #content { //html>body是CSS2的写法 width:500px; //支持CSS2该写法的浏览器有幸读到了这一句 } <!--[if Lte IE6]> #content { width:530px } <[!endif]--> 这里是一个width:500px;margin:10px;padding:10px; border:10px;的一个盒子,IE5.x Win解析不正常。IE6盒模型在向后兼容的同时也包容了以前的错误,IE6其实有两个核心,在旧的页面前他仍旧表现出对错误的宽容,只有在文档中严格地加上文档类型(DOCTYPE)声明,IE6才能够接受正确的box-model所以,hack必须和正确的DOCTYPE同时包含在文档中才能够正常工作。 IE/div浮动文本出现3px间距的bug

这里是浮动box

 

 

左边对象是浮动的,这里是采用margin-left来定位,这里的文本会离左边有3px的空白误差。

这里是浮动box,使用了* html #floatbox2 {margin-right: -3px;}解决3px bug

左边对象是浮动的,这里是采用* html p.no3px{height:1%;margin-left: 0;},这里的文本会离左边没有了3px的空白误差。

IE/div浮动文本出现3px间距的bug产生的条件:当左边对象是浮动的,右边对象采用外补丁的左边距(margin-left:?px;)来定位,则右边对象内的文本会离左边有3px的空白误差。

CSS: #ie3px{float: left; width: 100px; height: 50px; background: #f60;} p.ie3px{margin: 0 0 0 100px; background: #333; text-align:left; color:#fff;} XHTML: <div id="ie3px">这里是浮动box</div> <p class="ie3px">左边对象是浮动的,这里是采用margin-left来定位,这里的文本会离左边有3px的空白误差。</p>

IE/div浮动文本出现3px间距的bug解决方法: 利用hack *html div{}为IE单独写一个样式

* html #ieno3px{margin-right:-3px;} * html p.no3px{height:1%;margin-left: 0;} CSS: #ieno3px{float: left; width: 100px; height: 50px; background: #f60;} p.no3px{margin: 0 0 0 100px; background: #333; text-align:left; color:#fff;} * html #ieno3px{margin-right:-3px;} * html p.no3px{height:1%;margin-left: 0;} XHTML: <div id="ieno3px">这里是浮动box,使用了<span class="alt">* html #floatbox2 {margin-right: -3px;}</span>解决3px bug</div> <p class="no3px">左边对象是浮动的,这里是采用<span class="alt">* html p.no3px{height:1%;margin-left: 0;}</span>,这里的文本会离左边没有了3px的空白误差。</p> IE/浮动对象外补丁的双倍距离 这个元素,浮动左对齐(float:left),左侧外补丁(margin-left:50px;),在wrap层内,但在IE浏览器中Box1离左边的距离会是100px,而实际距离应是50px。当一个元素用于非float:none;的浮动状态时,IE下该元素既被视为块级元素,display:block; CSS: #box1{ margin-left:50px; float:left; background:#f60; width:200px;} XHTML: <div class="wrap"> <div id="box1">这个元素,浮动左对齐(float:left),左侧外补丁(margin-left:50px;),在wrap层内,但在IE浏览器中Box1离左边的距离会是100px,而实际距离应是50px。当一个元素用于非float:none;的浮动状态时,IE下该元素既被视为块级元素,display:block; </div> </div> 这是个拥有正确margin-left的元素,解决的办法就是,使浮动效果消失,这里采用了display:inline;原理可参阅on having layout。 CSS: #box2{ margin-left:50px; float:left; background:#f60; width:200px; display:inline ;} XHTML: <div class="wrap"> <div id="box2">这是个拥有正确margin-left的元素,解决的办法就是,使浮动效果消失,这里采用了display:inline;原理可参阅on having layout。</div> </div> [Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章