css中設定font-family的執行個體介紹

來源:互聯網
上載者:User
font-family版本:CSS1  相容性:IE4+ NS4+ 繼承性:有

文法:

font-family : name font-family : cursive | fantasy | monospace | serif | sans-serif


參數:

name : 字型名稱。按優先順序排列。以逗號隔開。如果字型名稱包含空格,則應使用引號括起
第二種聲明方式使用所列出的字型序列名稱。如果使用fantasy序列,將提供預設字型序列

說明:

設定或檢索用於對象中文本的字型名稱序列。
預設值由瀏覽器確定。
序列可包含嵌入字型字型。請參閱@font-face規則。
對應的指令碼特性為fontFamily。請參閱我編寫的其他書目。
樣本:

div.fixedwidth { font-family: Courier, "Courier New", monospace }

為什麼在css中設定了font-family:" 微軟雅黑"沒有用?

建議使用font-family: "Microsoft YaHei";
支援UTF-8和GB2312字元集。
不生效的3種情況:
1.當此屬性定義的是全域樣式時,對於表單類的標籤就不會生效,還需要再次定義如:
body {font-family: "Microsoft YaHei";}對錶單input就不生效,
還需要定義一個input {font-family: "Microsoft YaHei";}才可以。

2.本機電腦不存在微軟雅黑字型,有的系統預設沒有微軟雅黑,則一般預設為宋體,只要下載一個微軟雅黑字型,安裝後即可。

3.還有一個是字元集問題,建議把中文font-family:" 微軟雅黑";改為font-family: "Microsoft YaHei";字元集申明一下UTF-8或GB2312。

相關文章

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.