用CSS靈活設定字型大小

來源:互聯網
上載者:User
用DIV+css來寫網站結構也有一段時間,在此過程中發現有時候需要把字型設定成比12px,而比14px小的字型(13px在IE中無法區分出大小來和12px一樣)。今天發現用 font-size:small; 可以很好控制好字型的大小。

  首先設定一個基礎值在標籤中

body{font-size:small;}

  以這個字型大小為基礎,在其他標籤中設定百分比

h1{font-size:120%;}
h2{ font-size:110%;}
note{font-size:80%;}

  隨著基礎值的改變,其他字型也都會跟著改變,要修改的時候只需要修改body裡的基礎值。

  用small作為基礎值可以使使用者根據喜好隨意調整大小,使用者的調整不影響整體字型的比例失調。同時,當你按下Ctrl+滾動滑鼠中鍵時,還可以縮放頁面的字型大小。

相關文章

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.