font-weight
åºçº¿
广æ³å¯ç¨
èª 2015å¹´7æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
font-weight CSS 屿§æå®äºåä½çç²ç»ç¨åº¦ãä¸äºåä½åªæä¾ normal å bold 两ç§å¼ã
å°è¯ä¸ä¸
font-weight: normal;
font-weight: bold;
font-weight: lighter;
font-weight: bolder;
font-weight: 100;
font-weight: 900;
<section id="default-example">
<p id="example-element">
London. Michaelmas term lately over, and the Lord Chancellor sitting in
Lincoln's Inn Hall. Implacable November weather. As much mud in the streets
as if the waters had but newly retired from the face of the earth, and it
would not be wonderful to meet a Megalosaurus, forty feet long or so,
waddling like an elephantine lizard up Holborn Hill.
</p>
</section>
section {
font-size: 1.2em;
}
/* Keyword values */
font-weight: normal;
font-weight: bold;
/* Keyword values relative to the parent */
font-weight: lighter;
font-weight: bolder;
/* Numeric keyword values */
font-weight: 1
font-weight: 100;
font-weight: 100.6;
font-weight: 123;
font-weight: 200;
font-weight: 300;
font-weight: 321;
font-weight: 400;
font-weight: 500;
font-weight: 600;
font-weight: 700;
font-weight: 800;
font-weight: 900;
font-weight: 1000;
/* Global values */
font-weight: inherit;
font-weight: initial;
font-weight: unset;
| åå§å¼ | normal |
|---|---|
| éç¨å ç´ | ææå
ç´ åææ¬. It also applies to ::first-letter and ::first-line. |
| æ¯å¦æ¯ç»§æ¿å±æ§ | æ¯ |
| 计ç®å¼ | the keyword or the numerical value as specified, with bolder and lighter transformed to the real value |
| å¨ç»ç±»å | æè®¡ç®å¼çç±»å |
è¯æ³
>å¼
normal-
æ£å¸¸ç²ç»ãä¸
400çå¼ã bold-
å ç²ãä¸
700çå¼ã lighter-
æ¯ä»ç¶å ç´ ç»§æ¿æ¥ç弿´ç» (å¤å¨åä½å¯è¡çç²ç»å¼èå´å )ã
bolder-
æ¯ä»ç¶å ç´ ç»§æ¿æ¥ç弿´ç² (å¤å¨åä½å¯è¡çç²ç»å¼èå´å )ã
<number>-
ä¸ä¸ªä»äº 1 å 1000 (å å«) ä¹é´ç
<number>ç±»åå¼ãæ´å¤§çæ°å¼ä»£è¡¨åä½ééç²äºæ´å°çæ°å¼ (æä¸æ ·ç²)ãä¸äºå¸¸ç¨çæ°å¼å¯¹åºäºéç¨çåä½ééåç§°ï¼å¦ç« è常è§ç²ç»å¼åç§°åæ°å¼å¯¹åºææè¿°ã
åéæºå¶
妿æå®çæéå¼ä¸å¯ç¨ï¼å使ç¨ä»¥ä¸è§åæ¥ç¡®å®å®é åç°çæéï¼
-
妿æå®çæéå¼å¨
400å500ä¹é´ï¼å æ¬400å500ï¼ï¼- æååºæ¥æ¾æå®å¼ä¸
500ä¹é´çå¯ç¨æéï¼ - å¦ææªæ¾å°å¹é é¡¹ï¼æéåºæ¥æ¾å°äºæå®å¼çå¯ç¨æéï¼
- å¦ææªæ¾å°å¹é
é¡¹ï¼æååºæ¥æ¾å¤§äº
500çå¯ç¨æéã
- æååºæ¥æ¾æå®å¼ä¸
-
妿æå®å¼å°äº
400ï¼æéåºæ¥æ¾å°äºæå®å¼çå¯ç¨æéãå¦ææªæ¾å°å¹é é¡¹ï¼æååºæ¥æ¾å¤§äºæå®å¼çå¯ç¨æéï¼å å°½å¯è½çå°ï¼åå°½å¯è½ç大ï¼ã -
妿æå®å¼å¤§äº
500ï¼æååºæ¥æ¾å¤§äºæå®å¼çå¯ç¨æéãå¦ææªæ¾å°å¹é é¡¹ï¼æéåºæ¥æ¾å°äºæå®å¼çå¯ç¨æéï¼å å°½å¯è½ç大ï¼åå°½å¯è½çå°ï¼ã
以ä¸çç¥æå³çï¼å¦æä¸ä¸ªåä½åªæ normal å bold 两ç§ç²ç»å¼éæ©ï¼æå®ç²ç»å¼ä¸º 100-500 æ¶ï¼å®é
æ¸²ææ¶å°ä½¿ç¨ normalï¼æå®ç²ç»å¼ä¸º 501-900 æ¶ï¼å®é
æ¸²ææ¶å°ä½¿ç¨ bold ã
ç¸å¯¹ç²ç»å¼çè§£æ
彿å®çæ¯ç¸å¯¹ç²ç»å¼ lighter æ bolder æ¶ï¼å°ä½¿ç¨å¦ä¸å¾è¡¨æ¥å³å®å
ç´ æ¸²ææ¶çç»å¯¹ç²ç»å¼ï¼
| ç»§æ¿å¼ï¼Inherited valueï¼ | bolder |
lighter |
|---|---|---|
| 100 | 400 | 100 |
| 200 | 400 | 100 |
| 300 | 400 | 100 |
| 400 | 700 | 100 |
| 500 | 700 | 100 |
| 600 | 900 | 400 |
| 700 | 900 | 400 |
| 800 | 900 | 700 |
| 900 | 900 | 700 |
常è§ç²ç»å¼åç§°åæ°å¼å¯¹åº
100 å° 900 ä¹é´çæ°å¼å¤§è´å¯¹åºå¦ä¸ç常è§ç²ç»å¼åç§°ï¼
æå¼è§å¾
font-weight æ°å¼éå离æ£å¼å®ä¹ï¼ä½¿ç¨ 100 çæ´åæ°ï¼ãæ°å¼ä¸ºå®æ°ï¼é 100 çæ´æ°åçå¼å°è¢«åèäºå
¥è½¬æ¢ä¸º 100 çæ´åæ°ï¼éå° *50 æ¶ï¼å°åä¸è½¬æ¢ï¼å¦ 150 å°è½¬æ¢ä¸º 200ã
å½¢å¼è¯æ³
font-weight =
<font-weight-absolute> |
bolder |
lighter
<font-weight-absolute> =
normal |
bold |
<number [1,1000]>
示ä¾
>HTML
<p>
Alice was beginning to get very tired of sitting by her sister on the bank,
and of having nothing to do: once or twice she had peeped into the book her
sister was reading, but it had no pictures or conversations in it, 'and what
is the use of a book,' thought Alice 'without pictures or conversations?'
</p>
<div>
I'm heavy<br />
<span>I'm lighter</span>
</div>
CSS
/* Set paragraph text to be bold. */
p {
font-weight: bold;
}
/* Set div text to two steps darker than
normal but less than a standard bold. */
div {
font-weight: 600;
}
/* Sets text enclosed within span tag
to be one step lighter than the parent. */
span {
font-weight: lighter;
}
ç»æ
è§è
| è§è |
|---|
| CSS Fonts Module Level 4 > # font-weight-prop > |