我對這種 CSS 樣式非常陌生,我了解到您可以像下面這樣定義樣式:
.header {
color: black;
font-family: "Calibri, sans-serif";
font-size:18px;
}
.body {
color: black;
font-family: "Calibri, sans-serif";
font-size:12px;
}
.footnote {
color: black;
font-family: "Calibri, sans-serif";
font-size:10px;
}
然后把它放在代碼中:
<p class = "header"> THIS IS HEADER </p>
<p class = "body"> THIS IS BODY </p>
<p class = "footnote"> THIS IS Footnote </p>
我的問題是,由于標題、正文、腳注都共享相同的字體,我唯一需要的更改是更改字體大小,有沒有辦法只呼叫一次樣式并更改字體大小?
謝謝
uj5u.com熱心網友回復:
.header,.body,.footnote{
color: black;
font-family: "Calibri, sans-serif" ;
}
<p class = "header" style="font-size:18px;"> THIS IS HEADER </p>
<p class = "body" style="font-size:12px;"> THIS IS BODY </p>
<p class = "footnote" style="font-size:10px;"> THIS IS Footnote </p>
或者您可以創建一個公共類并改用它并傳遞每個元素不同的行內 css
.common-style{
color: black;
font-family: "Calibri, sans-serif";
}
<p class = "common-style" style="font-size:18px;"> THIS IS HEADER </p>
<p class = "common-style" style="font-size:12px;"> THIS IS BODY </p>
<p class = "common-style" style="font-size:10px;"> THIS IS Footnote </p>
uj5u.com熱心網友回復:
您還可以定義全域主體樣式,如果它們尚未設定任何樣式,則將應用于所有元素。此外,為 body 元素定義一些默認樣式也是一種很好的做法。
像這樣的東西:
body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: normal;
line-height: 1.5;
color: black;
-webkit-font-smoothing: antialiased; // Smooth the font on the level of the pixel, as opposed to the subpixel. Switching from subpixel rendering to antialiasing for light text on dark backgrounds makes it look lighter.
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/361874.html
上一篇:影片輸入后的CSS影片輸出
下一篇:h1相對于父級的中心跨度
