rem(font size of the root element)是指相對於根元素的字體大小的單位 1)若是html
html{font-size:14px;}字體
那麼htm
在網頁中我想設置一個42px的寬度,就能夠用42/14=3rem;element
在網頁中我想設置一個70px的寬度,就能夠用42/14=5rem;rem
在網頁中我想設置一個90px的寬度,就能夠用42/14=6.42rem;樣式
(2)若是html標籤沒有設置font-size,那麼默認是1rem=16px;標籤
建議是html,body{font-size:62.5%;}
這樣的話,在設置其餘樣式的時候方便多了,1rem=10px;
我想設置一個20px的寬,那麼就是2rem;
我想設置一個8px的高,那麼就是0.8rem;