outline-offset CSS property sets the amount of space between an outline and the edge or border of an element.

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.

句法

/* <length> values */
outline-offset: 3px;
outline-offset: 0.2em;
/* Global values */
outline-offset: inherit;
outline-offset: initial;
outline-offset: unset;
					

<length>
The width of the space between the element and its outline. A negative value places the outline inside the element. A value of 0 places the outline so that there is no space between it and the element.

描述

An outline is a line that is drawn around an element, outside the border edge. The space between an element and its outline is transparent. In other words, it is the same as the parent element's background.

形式定义

初始值 0
适用于 所有元素
继承 no
计算值 as specified, but with relative lengths converted into absolute lengths
动画类型 a length

形式句法

<length>
					

范例

Setting outline offset in pixels

HTML

<p>Gallia est omnis divisa in partes tres.</p>
					

CSS

p {
  outline: 1px dashed red;
  outline-offset: 10px;
  background: yellow;
  border: 1px solid blue;
  margin: 15px;
}
					

结果

规范

规范 状态 注释
CSS Basic User Interface Module Level 3
The definition of 'outline-offset' in that specification.
推荐 初始定义

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
outline-offset Chrome 完整支持 1 Edge 完整支持 15 Firefox 完整支持 1.5 IE 不支持 No Opera 完整支持 9.5 Safari 完整支持 1.2 WebView Android 完整支持 37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: