在CSS中,可以使用font-size
屬性來改變字體的大小,這個屬性可以設(shè)置一個具體的像素值,或者是一個相對的大?。ㄈ?code>larger、smaller
),以下是一些示例:
1、設(shè)置為具體像素值:
p { font-size: 16px; }
2、設(shè)置為相對大?。?/p>
p { font-size: larger; }
3、繼承字體大小:
body { font-size: 16px; } h1 { font-size: 2em; /* 2 times the size of the body text */ }
4、使用rem
單位設(shè)置字體大?。?/p>
p { font-size: 1.6rem; /* 1.6 times the size of the root element */ }
rem
單位是基于根元素(html
元素)的字體大小的單位,如果根元素的字體大小未明確設(shè)置,則rem
單位將默認與像素值(px
)相同,在使用rem
單位之前,***好明確設(shè)置根元素的字體大小。
版權(quán)聲明:除非特別標注,否則均為本站原創(chuàng)文章,轉(zhuǎn)載時請以鏈接形式注明文章出處。