CSS font-size 屬性可以使用絕對(duì)和相對(duì)關(guān)鍵字來(lái)設(shè)置。這會(huì)根據(jù)需要縮放文本。
語(yǔ)法
CSS font-size 屬性的語(yǔ)法如下 –
Selector {
font-size: /*value*/
}
登錄后復(fù)制
下表列出了 CSS 中使用的標(biāo)準(zhǔn)關(guān)鍵字 –
| Sr.No | Value &描述 |
|---|---|
| 1 | 中
設(shè)置字體大小到中等尺寸。這是默認(rèn)值 |
| 2 | xx-small
集將字體大小設(shè)置為 xx-small 尺寸 |
| 3 | x-small
將字體大小設(shè)置為特別小 |
| 4 | 小
將字體大小設(shè)置為較小尺寸 |
| 5 | large
將字體大小設(shè)置為大尺寸 |
| 6 | x-large
將字體大小設(shè)置為超大尺寸 |
| 7 | xx-large
將字體大小設(shè)置為xx-large尺寸 |
| 8 | 較小
將字體大小設(shè)置為小于父元素 |
| 9 | 更大
將字體大小設(shè)置為比父元素更大的大小 |
以下示例說(shuō)明了如何使用關(guān)鍵字設(shè)置 CSS font-size 屬性。
示例
?現(xiàn)場(chǎng)演示
<!DOCTYPE html>
<html>
<head>
<style>
h1{
font-size: larger;
}
#demo {
font-size: medium;
text-align: center;
background-color: floralwhite;
}
p {
font-size: xx-large;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<p id="demo">This is demo text.</p>
<p>This is another demo text.</p>
</body>
</html>
登錄后復(fù)制
輸出
這給出了以下輸出 –
示例
?現(xiàn)場(chǎng)演示
<!DOCTYPE html>
<html>
<head>
<style>
div {
margin: auto;
padding: 5px;
width: 30%;
border: 1px solid;
border-radius: 29%;
text-align: center;
font-size: xx-small;
}
p {
font-size: xx-large;
}
</style>
</head>
<body>
<div>
<div>One</div>
<p>Two</p>
</div>
</body>
</html>
登錄后復(fù)制
輸出
這給出了以下輸出 –
以上就是使用 CSS 設(shè)置關(guān)鍵字的字體大小的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!






