分享

Bugs及解决方案列表

 偶记易方 2018-07-12
<style>
html,body{margin: 0;padding: 0;}
.test{background: red;width:400px;height: 20px;}
</style>

1. 如何在IE6及更早浏览器中定义小高度的容器?
<style>
.test1{height:1px;}
.test1{overflow:hidden;}
</style>   
<div class="test test1">1</div>

<!-- IE6及更早浏览器之所以无法直接定义较小高度的容器是因为默认会有行高 -->


2. 如何解决IE6及更早浏览器浮动时产生双倍边距的BUG?
<style>
.test2{margin:20px;float: left;}
.test2{display:inline;}
</style>
<div class="test test2">2</div>
<!-- 当在IE6及更早浏览器中出现浮动后margin值解析为双倍的情况,设置该元素的display属性为inline即可。 -->


3. 如何在IE6及更早浏览器下模拟min-height效果?
<style>
.test3{ min-height:100px;width: 30px;background: #ccc; }
.test3{ _height:100px; }
</style>
<div class="test test3">3</div>
<!-- 注意此时.test3不能再设置overflow的值为hidden,否则模拟min-height效果将失效 -->


4. 如何解决按钮在IE7及更早浏览器下随着value增多两边留白也随着增加的问题?
<style>
input,button{overflow:visible;}
</style>
<input type="button" value="4史蒂芬霍金史蒂芬霍金">

   
5. 如何解决IE6及更早浏览器下的3像素BUG?
<style>
.a{color:#f00;}
.main{width:350px;background:red;}
.content{float:left;width:250px;height:100px;background:yellow;}
.content{_margin-right:-3px;}
.aside{height:100px;background:#aaa;}
</style>

<div class="main">
<div class="content">5content</div>
<div class="aside">5aside</div>
</div>
<!-- 在IE6及更早浏览器下为.content设置margin-right:-3px -->


6. 如何解决IE6下的文本溢出BUG?
<style>
.test6{zoom:1;overflow:hidden;width:500px;/*_height: 16px;*/}
.box1{float:left;width:100px;}
.box2{/*float:right;*/width:400px;}
.box2{margin-left: 100px;}
</style>

<div class="test6">
<div class="box1"></div>
<!-- 注释 -->
<div class="box2">↓6这就是多出来的那只猪</div>
</div>
<!-- 运行如上代码,你会发现文字发生了溢出,在IE6下会多出一只“猪”。造成此BUG的原因可能是多重混合的,如浮动,注释,宽高定义等等。并且注释条数越多,溢出的文本也会随之增多
列举几个解决方法:
1. 删除box1和box2之间所有的注释(**)
2. 不设置浮动,将float:right; 改为 margin-left: 100px;
3. 设置ie6下的test6的高度 _height: 16px; 
4. 调整box1或box2的宽度,比如将box的宽度调整为90px????
 -->


7. 如何解决IE6无法识别伪对象:first-letter/:first-line的问题?
<style>
/* 方法1 */
/* 增加空格:在伪对象选择符:first-letter/:first-line与包含规则的花括号"{"间增加空格 */
p.p1:first-letter {float:left;font-size:40px;font-weight:bold;}
p.p1:first-line {color:#090;}

/* 方法2 */
 /* 换行:将整个花括号"{"规则区域换行。细节参见E:first-letter和E:first-line选择符 */
p.p1:first-letter
{float:left;font-size:40px;font-weight:bold;}
p.p1:first-line
{color:#090;}
</style>

<p class="p1">陌上人如玉公子世无双<br>陌上人如玉公子世无双7</p>


8. 如何解决IE8会忽略伪对象:first-letter/:first-line里的!important规则的问题?
<style>
.p2:first-letter {
float:left; font-size:40px; font-weight:bold;
color:#f00!important; color:#090;
}
</style>
<p class="p2">陌上人如玉公子世无双<br>陌上人如玉公子世无双8</p>

<!-- 如上代码,在IE8下color定义都会失效,原因就是因为有color使用了!important规则。鉴于此,请尽量不要在:first-letter/:first-line里使用!important规则。 -->



9. 如何解决IE6会忽略同一条样式体内的!important规则的问题?
<style>
.test9{color:#f00!important;}
.test9{color:#000;}
</style>

<div class="test9">陌上人如玉公子世无双9</div>

<!-- 如上代码,IE6及以下浏览器div的文本颜色为#000,!important并没有覆盖后面的规则,也就是说!important被忽略了。解决方案是将该样式拆分为2条,细节参见!important规则 -->




10. 如何解决IE6及更早浏览器下当li内部元素定义了display:block的内联元素时底部产生空白的问题?
<style>
.ul10 a,span{display:block;background:#ddd;}
.ul10 a,span{zoom:1}
</style>

<ul class="ul10">
<li><a href="http://css./">10CSS参考手册</a></li>
<li><a href="http://blog./">10CSS探索之旅</a></li>
<li><a href="http://demo./">10web前端实验室</a>
</li><li><span>10测试ie6- li内部元素为设置了display:block的内联元素时底部产生空白</span></li>
</ul>

<!-- 如上代码,IE6及更早浏览器每个li内部的内联元素底部都会产生空白。解决方案是给li内部的内联元素再加上zoom:1 -->



11. 如何解决IE6及更早浏览器下未定义宽度的浮动或绝对定位元素会被内部设置了zoom:1的块元素撑开?
<style>
.test11{zoom:1;overflow:hidden;border:1px solid #ddd;background:#eee;}
.test11 h1{float:left;}
.test11 .nav{float:right;background:#aaa;}
.test11 .nav ul{zoom:1;overflow:hidden;margin:0;padding:0;list-style:none;}
.test11 .nav ul{float: left;}
/*.test11 .nav ul{display: inline;}*/
/*.test11 .nav ul{width: 600px;}*/
.test11 .nav li{float:left;margin:0 5px;}
</style>

<div class="test11">
<h1>Doyoe</h1>
<div class="nav">
<ul>
<li><a href="http://css./">11CSS参考手册</a></li>
<li><a href="http://blog./">11CSS探索之旅</a></li>
<li><a href="http://demo./">11web前端实验室</a></li>
</ul>
</div>
</div>
<!-- 如上代码,IE6及更早浏览器div.nav会被设置了zoom:1的ul给撑开。
列举几个解决方法:
1.设置ul为浮动元素;
2.设置ul为inline元素;
3.设置ul的width 
-->


12. 如何解决IE7及更早浏览器下子元素相对定位时父元素overflow属性的auto|hidden失效的问题?
<style>
.test12{overflow:auto;width:260px;height:80px;border:1px solid #ddd;}
.test12{position: relative;}
.test12 p{position:relative;margin:0;}
</style>
   
<div class="test12">
<p>12如果我是相对定位,我的父元素overflow属性设置为auto|hidden将失效。如果你使用的是IE及更早浏览器,你将可以看到这个BUG</p>
<p>12如果我是相对定位,我的父元素overflow属性设置为auto|hidden将失效。如果你使用的是IE及更早浏览器,你将可以看到这个BUG</p>
</div>

<!-- 如上代码,在IE7及更早浏览器下你会看到div的滚动条将无法工作。解决方案是给div也设置相对定位position:relative -->



13. 如何解决Chrome在应用transition时页面闪动的问题?(没感觉)
<style>
.test13{width: 200px;height: 100px;background: #f30;transition: width 1s; }
.test13:hover{width: 400px;}
.test13{
/* -webkit-transform-style:preserve-3d; */
-webkit-backface-visibility:hidden;
}
</style>
<div class="test13">13</div>
<!-- (
-webkit-transform-style:preserve-3d;   或者是
-webkit-backface-visibility:hidden;
 -->




<!-- 以下没懂 -->

<!-- 如何解决IE6使用滤镜PNG图片透明后,容器内链接失效的问题????? -->
<style>
.test7{width:300px;height:100px;
background: url(images/9.png);
/*_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/9.png');*/}
/*a{_position:relative;}*/
</style>
    <div class="test7"><a href="www.baidu.com" target="_blank">7baidu</a></div>


<!-- 解决方法是为容器内的链接定义相对定位属性position的值为relative -->



<!-- . 如何解决IE7及更早浏览器下当li中出现2个或以上的浮动时,li之间产生的空白间隙的BUG?????? -->
<style>
li.li1{float: left;}
li{vertical-align:top;}
</style>
<ul>
<li class="li1">
<img src="images/2.jpg" alt="" width="100px">
</li>
<li class="li2">
<img src="images/1.jpg" alt="" width="100px"> 
<img src="images/2.jpg" alt="" width="100px">
</li>
</ul>
<!-- 除了top值,还可以设置为text-top | middle | bottom | text-bottom,甚至特定的<length>和<percentage>值都可以 -->



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多