css中font屬性問題及其解決方案

來源:互聯網
上載者:User

屬性定義及使用說明

字型簡寫屬性在一個聲明中設定所有字型屬性。

可以設定的屬性是(按順序):

“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-familyfont-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,只能通過斜杠/組成
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.