css_ie6与ie8在调用float:left后margin不协调的调整

本文探讨了在IE6与IE8浏览器中出现的浮动元素margin-left双倍显示的问题及其解决方法。该问题仅发生在特定条件下,并提供了一个简单有效的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原型:<div style="float:left;margin-left:50px; background:red;width:50px; height:50px;" ></div>

在ie6与ie8中上面代码会让margin-left出现不协调:即ie6中margin-left值是ie8中margin-left的两倍(也是常规值的两倍),

重点

这个Bug仅当浮动边界和浮动元素的方向相同时出现在浮动元素和容器盒的内边缘之间,在这之后的任意有着相似边界的浮动元素不会呈现双倍边界。只有特定的浮动行的第一个浮动元素会遭遇这个Bug。像居左的情况一样,双倍边界同样神秘地显示在居右的相同方式。

inline 默认。此元素会被显示为内联元素,元素前后没有换行符。

修改方法:添加-display:inline;

修改后:<div style="float:left;display:inline;margin-left:50px; background:red;width:50px; height:50px;" ></div>

body { padding: 0; margin: 0 } #unity-container { position: absolute } #unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) } #unity-container.unity-mobile { position: fixed; width: 100%; height: 100% } #unity-canvas { background: {{{ BACKGROUND_COLOR }}} } .unity-mobile #unity-canvas { width: 100%; height: 100% } #unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none } #unity-logo { width: 154px; height: 130px; background: url('webgl-logo.png') no-repeat center } #unity-progress-bar-empty { width: 1000px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('frame_gaojing_nomal@2x.png') no-repeat center } #unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center } #unity-footer { position: relative } .unity-mobile #unity-footer { display: none } #unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px } #unity-fullscreen-button { cursor:pointer; float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center } #unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }我需要#unity-logo { width: 154px; height: 130px; background: url('webgl-logo.png') no-repeat center }这个logo在应用中间 然后#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }这个进度会从0到100加载 是一整条过去显示
最新发布
08-08
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值