+ -
当前位置:首页 → 问答吧 → span 固定宽度了,可是产生了行距。

span 固定宽度了,可是产生了行距。

时间:2010-10-02

来源:互联网


<style type="text/css"> BODY { background-color: #00ff00; font-family: "Tahoma", "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 12px; COLOR: #000; } span { background-color: #ffcc00; display: inline-block; width: 200px; font-size: 12px; } </style> <br><br> <div>Welcome to <span>武汉</span>欢迎您</div> <div>Welcome to <span>湖北武汉</span>欢迎您</div> <div>Welcome to <span>湖 北 武 汉</span>欢迎您</div>
 提示:您可以先修改部分代码再运行
span 固定宽度问题。宽度确实已经固定了。

可是在 FF 和 IE 下显示不 一样。IE 显示的有行距。FF 则正常。

我现在就是不想要这个行距。因为我实际的网页中,图片是上下分隔的,有行距后,则图片之间有间隔了。

我不是做网页设计行业的,碰到了这个问题,很苦恼呢。

[ 本帖最后由 gugong 于 2010-10-2 12:35 编辑 ]

附件

未标题-1.png (4 KB)

2010-10-2 12:31

作者: gugong   发布时间: 2010-10-02

我在ie6下看不到bug啊

作者: qiang5233   发布时间: 2010-10-02

测试了下好像是font-size的关系,另外最好给SPAN加个line-height:
<!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> <title>11111</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <style type="text/css"> BODY { background-color: #00ff00; font-family: "Tahoma", "Verdana", "Arial", "Helvetica", "sans-serif"; font-size: 12px; COLOR: #000; } span { background-color: #ffcc00; display:inline-block; width: 200px; font-size: 14px; line-height:20px; } </style> </head> <body> <div>Welcome to <span>武汉</span>欢迎您</div> <div>Welcome to <span>湖北武汉</span>欢迎您</div> <div>Welcome to <span>湖 北 武 汉</span>欢迎您</div> </body> </html>
 提示:您可以先修改部分代码再运行

作者: benzhuqq   发布时间: 2010-10-02