今天开发项目中碰到一个li在IE中的BUG,先来看设计原型(如图:)
两个红色中间是<li>1px的底边框;
我写的代码如下:
=============================================================
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>无标题文档</title>
<style type=”text/css”>
<!–
body,dl,dt,dd,ul,ol,li,pre,form,fieldset,input,p,blockquote,th,td,h1,h2,h3,h4,h4,h5{margin:0;padding:0}
body{font:400 12px/150% Tahoma,SimSun,Arial;color:#333;background-color:#FFFFFF}
select{font-size:12px}
ul,li{list-style:none}
img{border:none}
ul{ border-bottom:#FDD496 2px solid;border-top:#FDD496 2px solid; height:263px}
ul li{ height:43px; border-bottom:#DCDCDC 1px solid; }
.po-txt{ float:left; width:146px; height:31px; background-color:#f00; padding:12px 0 0; font-size:14px; font-weight:700; text-align:right}
–>
</style></head>
<body>
<ul>
<li>
<div class=”po-txt”>通行证:</div>
</li>
<li>
<div class=”po-txt”>昵称:</div>
</li>
</ul>
</body>
</html>
=================================================================
在IE6,IE7下显示为(如图):貌似<li>多了个 margin-bottom:3px;
几经周折,找到了Qzone的鬼哥帮忙解决,他说在<li>上加float:left;
问题解决了,当然根据设计稿的精神还要加个width:100%;
完整的样式如下:
=====================================================
<style type=”text/css”>
<!–
body,dl,dt,dd,ul,ol,li,pre,form,fieldset,input,p,blockquote,th,td,h1,h2,h3,h4,h4,h5{margin:0;padding:0}
body{font:400 12px/150% Tahoma,SimSun,Arial;color:#333;background-color:#FFFFFF}
select{font-size:12px}
ul,li{list-style:none}
img{border:none}
ul{ border-bottom:#FDD496 2px solid;border-top:#FDD496 2px solid; height:263px}
ul li{ height:43px; border-bottom:#DCDCDC 1px solid; float:left; width:100%;}
.po-txt{ float:left; width:146px; height:31px; background-color:#f00; padding:12px 0 0; font-size:14px; font-weight:700; text-align:right}
–>
</style>
======================================================
以前我们老是研究清除浮动,想不到今天却用增加浮动来解决问题。呵呵。
特别感谢Qzone的鬼哥!