CSS: body{font-size: 62.5%;}為什么???


在網頁設計中我們經常看見body{font-size: 62.5%;}這樣的設置,為什么偏偏是62.5%呢?這主要是為了方便em與px相互轉換,em的初始值為1em=16px,顯然這樣的話,如1.2em則=19.2px,可是我們在設置的時候很少看見19.2px這樣表示的大小,也就是在用px表示大小時數值是不帶小數位的。當設置了body{font-size: 62.5%;}時,1em則=16px*62.5%=10px,1.2em則=12px,這是不是就簡單多了,准確多了呢~~

 

Set body font-size to 62.5% for Easier em Conversion

If you would like to use relative units (em) for your font sizes, declaring 62.5% for the font-size property of the body will make it easier to convert px to em. By doing it this way, converting to em is a matter of dividing the px value by 10 (e.g. 24px = 2.4em).

 

code:

body {
  font-size: 62.5%;
}
p {
  font-size: 1.2em;
}




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM