border-top-width
åºçº¿
广æ³å¯ç¨
èª 2015å¹´7æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
css 屿§ border-top-width æ¯ç¨äºè®¾ç½®ç模åçä¸è¾¹æ¡ç宽度
å°è¯ä¸ä¸
border-top-width: thick;
border-top-width: 2em;
border-top-width: 4px;
border-top-width: 2ex;
border-top-width: 0;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
This is a box with a border around it.
</div>
</section>
#example-element {
background-color: palegreen;
color: #000;
border: 0 solid crimson;
padding: 0.75em;
width: 80%;
height: 100px;
}
Syntax
css
/* Keyword values */
border-top-width: thin;
border-top-width: medium;
border-top-width: thick;
/* <length> values */
border-top-width: 10em;
border-top-width: 3vmax;
border-top-width: 6px;
/* Global keywords */
border-top-width: inherit;
border-top-width: initial;
border-top-width: unset;
Values
<br-width>-
ä¸è¾¹æ¡çå®½åº¦å±æ§çææå¼è¦ä¹æ¯ä¸ä¸ªå ·ä½çéè´æ°ï¼è¦ä¹æ¯ä¸ä¸ªå ³é®åã妿æ¯å ³é®åï¼å¿ é¡»æ¯ä¸ä¸å ç§ï¼
thinA thin border mediumA medium border thickA thick border 夿³¨ï¼Because the specification doesn't define the exact thickness denoted by each keyword, the precise result when using one of them is implementation-specific. Nevertheless, they always follow the pattern
thin ⤠medium ⤠thick, and the values are constant within a single document.
Formal syntax
border-top-width =
<line-width>
<line-width> =
<length [0,â]> |
hairline |
thin |
medium |
thick
Example
>HTML
html
<div>Element 1</div>
<div>Element 2</div>
CSS
css
div {
border: 1px solid red;
margin: 1em 0;
}
div:nth-child(1) {
border-top-width: thick;
}
div:nth-child(2) {
border-top-width: 2em;
}
Result
Specifications
| è§è |
|---|
| CSS Backgrounds and Borders Module Level 3> # border-width> |
| åå§å¼ | medium |
|---|---|
| éç¨å ç´ | ææå
ç´ . It also applies to ::first-letter. |
| æ¯å¦æ¯ç»§æ¿å±æ§ | å¦ |
| 计ç®å¼ | ç»å¯¹é¿åº¦ï¼æå¦æ border-top-style çå¼ä¸º none æ hiddenï¼å为 0 |
| å¨ç»ç±»å | a length |
Browser compatibility
See also
- The other border-width-related CSS properties:
border-left-width,border-right-width,border-bottom-width, andborder-width. - The other border-top-related CSS properties:
border,border-top,border-top-style, andborder-top-color.