outline-width

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.

CSS 属性 outline-width 用于设置一个元素的轮廓的厚度。元素轮廓是绘制于元素周围的一条线,位于 border 的外围。

尝试一下

大多情况下用简写属性 outline 定义轮廓外观会更方便。

Syntax

css
/* 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

outline-width = 
<line-width>

<line-width> =
<length [0,∞]> |
thin |
medium |
thick

Examples

HTML

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

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
CSS Basic User Interface Module Level 4
# outline-width
初始值medium
适用元素所有元素
是否是继承属性
计算值绝对长度;如果指定关键词为 none,则计算值为 0
动画类型a length

Browser compatibility

BCD tables only load in the browser