IE下中英文混排bug

这个bug很常见,首先看示例代码:

<!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=gb2312" />
<title>000</title>
<style type="text/css">
*{margin:0; padding:0;}
body{font-size:12px; color:#333;}
#list{font-family:Arial; list-style:none;}
#list li{float:left;margin-right:10px;}
</style>
</head>
<body>
<ul id="list"><li>12条留言</li><li>回复</li></ul>
</body>
</html>
IE下中英文混排bug

IE下中英文混排bug

这个bug导致基线不一致,解决方法有如下几种:

修改字体为宋体,但是宋体的英文字体为衬线字体(Times New Roman即是英文中的衬线字,关于衬线字)

<!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=gb2312" />
<title>000</title>
<style type="text/css">
*{margin:0; padding:0;}
body{font-size:12px; color:#333;}
#list{font-family:"宋体"; list-style:none;}
#list li{float:left;margin-right:10px;}
</style>
</head>
<body>
<ul id="list"><li>12条留言</li><li>回复</li></ul>
</body>
</html>

为了更加美观,所以英文采用arial字体,中文使用宋体。可在<a>标签内注明 line-height:1.231,可解决行高不等以及字体与下划线粘连问题。代码如下:

<!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=gb2312" />
<title>000</title>
<style type="text/css">
*{margin:0; padding:0;}
body{font-size:12px; color:#333;}
#list{font-family:Arial,"宋体";  list-style:none;}
#list li{float:left;margin-right:10px;line-height:1.231;}
</style>
</head>
<body>
<ul id="list"><li>12条留言</li><li>回复</li></ul>
</body>
</html>

杯具的事情还是发生了OP有和IE一样的bug而且用line-height解决不了,只能将字体设置为宋体解决问题。

参考文献:网页中英文混排行高不等问题的解决方案探讨

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>