A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

转载:https://www.jb51.net/article/9995.htm
针对同一HTML标记,在CSS中同时应用了font和line-height属性时,就得小心了,这二者的书写顺序不一样,会导致显示效果不同。
即:
>>> 如果先写font,再写line-height,显示效果正常
>>> 如果先写line-height,再写font,则line-height定义的效果会丢失,在IE、Firefox、Opera下都出现这种BUG

具体效果请看以下代码:

<p>h1:</p>
<h1 style="background:#f00;margin:5px 0;font:bold 20px 宋体,Geneva,Arial,sans-serif;line-height:40px;">IECN.Net - 专注Web技术,体验开发乐趣!</h1>
<h1 style="background:#f00;margin:5px 0;line-height:40px;font:bold 20px 宋体,Geneva,Arial,sans-serif;">IECN.Net - 专注Web技术,体验开发乐趣!</h1>

<p>div:</p>
<div style="background:#f00;margin:5px 0;font:bold 20px 宋体,Geneva,Arial,sans-serif;line-height:40px;">IECN.Net - 专注Web技术,体验开发乐趣!</div>
<div style="background:#f00;margin:5px 0;line-height:40px;font:bold 20px 宋体,Geneva,Arial,sans-serif;">IECN.Net - 专注Web技术,体验开发乐趣!</div>



引用
对font的定义参数必须按照如下的排列顺序。每个参数仅允许有一个值。忽略的将使用其参数对应的独立属性的默认值:
font : font-style || font-variant || font-weight || font-size || line-height || font-family  
例子:p { font: italic small-caps 600 12pts/18pts 宋体; }

2 个回复

倒序浏览

点评

谢谢,这是工作中遇到的问题  发表于 2018-9-21 09:59
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马