outline-width
CSS 属性 outline-width
用于设置一个元素的轮廓的厚度。元素轮廓是绘制于元素周围的一条线,位于 border
的外围。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
大多情况下用简写属性 outline
定义轮廓外观会更方便。
Syntax
/* Keyword values */
outline-width: thin;
outline-width: medium;
outline-width: thick;
/* <length> values */
outline-width: 1px;
outline-width: 0.1em;
/* Global values */
outline-width: inherit;
outline-width
的值可以是下面列表中的任一项。
Values
<length>
- The width of the outline specified as a
<length>
. thin
- 取决于用户代理。通常等同于桌面浏览器的
1px
(包括 Firefox)。 medium
- 取决于用户代理。通常等同于桌面浏览器的
3px
(包括 Firefox)。 thick
- 取决于用户代理。通常等同于桌面浏览器的
5px
(包括 Firefox)。
Formal syntax
Examples
HTML
<span id="thin">thin</span>
<span id="medium">medium</span>
<span id="thick">thick</span>
<span id="twopixels">2px</span>
<span id="oneex">1ex</span>
<span id="em">1.2em</span>
CSS
span {
outline-style: solid;
display: inline-block;
margin: 20px;
}
#thin {
outline-width: thin;
}
#medium {
outline-width: medium;
}
#thick {
outline-width: thick;
}
#twopixels {
outline-width: 2px;
}
#oneex {
outline-width: 1ex;
}
#em {
outline-width: 1.2em;
}
Specifications
Specification | Status | Comment |
---|---|---|
CSS Basic User Interface Module Level 3 outline-width |
Recommendation | No change. |
CSS Transitions outline-width |
Working Draft | Defines outline-width as animatable. |
CSS Level 2 (Revision 1) outline-width |
Recommendation | Initial definition. |
初始值 | medium |
---|---|
适用元素 | all elements |
是否是继承属性 | 否 |
计算值 | an absolute length; if the keyword none is specified, the computed value is 0 |
Animation type | a length |
Browser compatibility
BCD tables only load in the browser