当前位置:Gxlcms > css > css中font属性问题及其解决方法

css中font属性问题及其解决方法

时间:2021-07-01 10:21:17 帮助过:91人阅读

属性定义及使用说明

字体简写属性在一个声明中设置所有字体属性。

可以设置的属性是(按顺序):

“font-style font-variant font-weight font-size / line-height font-family”

字体大小和字体家庭的值是必需的。如果缺少了其他值,默认值将被插入,如果有默认值的话。

css中font属性问题,字体和行高

前面 先设置的是 font-size, 后面才是 line-height;刚刚在chrome测试了下 ,单独写 font: 10px/1.5em; 是无效的。但是 在后面加上font-family就可以。比如: font: 10px/1.5em arial,verdana;或者写成 font: 10px/1.5em "";也是有效的。font前面的简写属性可以不写,但是font-family属性一定要写否则就无效。完整的font简写属性 font:italic small-caps bold 12px/1.5em arial,verdana; 建议只是设置行高 和 字体大小 没必要使用简写属性。可以参考bootstrap对使用简写属性的建议。

为什么css中font合写不管用

body{
font:62.5% Arial, Helvetica, sans-serif,"宋体";
}
.nav li{
font:1.6em/54px;
}
"font:1.6em/54px"不管用
把font:1.6em/54px改为font:54px/1.6em;即可,建议书写完整。
简写顺序:font-style | font-variant | font-weight | font-size | line-height | font-family
font-style:italic;
font-variant:small-caps;
font-weight:bold;
font-size:12px;
line-height:1.5em;
font-family:arial,verdana;
简写格式:
font:italic small-caps bold 12px/1.5em arial,verdana;
说明:简写时font-size和line-height,只能通过斜杠/组成

以上就是css中font属性问题及其解决方法的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行