这篇翻译不完整。请帮忙从英语翻译这篇文章。
概述
CSS outline
属性 是一个 shorthand 属性为一个或多个独立的轮廓属性outline-style
, outline-width
and outline-color
in a single declaration. In most cases the use of this shortcut is preferable and more convenient.
Outlines differ from borders in the following ways:
- Outlines do not take up space, they are drawn above the content.
- Outlines may be non-rectangular. They are rectangular in Gecko/Firefox. But e.g. Opera draws a non-rectangular shape around a construct like this:
TEXTTEXTTEXT
初始值 | as each of the properties of the shorthand:
|
---|---|
适用元素 | all elements |
是否是继承属性 | 否 |
适用媒体 | visual, interactive |
计算值 | as each of the properties of the shorthand:
|
是否适用于 CSS 动画 | as each of the properties of the shorthand:
|
正规顺序 | order of appearance in the formal grammar of the values |
语法
/* width | style | color */ outline: 1px solid white;
取值
One, two or three values, given in arbitrary order:
<'outline-width'>
- See
outline-width
. <'outline-style'>
- See
outline-style
. <'outline-color'>
- Since Gecko 1.9 (Firefox 3), the value of the element's
color
property (foreground color) is used. Seeoutline-color
.
形式化语法
[ <'outline-color'> || <'outline-style'> || <'outline-width'> ]
例子
outline: solid; | outline: dashed red; | outline: dotted 1px; | outline: ridge thick violet; | outline: custom 5px;
/* two identical declarations */ :link:hover { outline: 1px solid #000; } :link:hover { outline: solid black 1px; }
规范
Specification | Status | Comment |
---|---|---|
CSS Basic User Interface Module Level 3 outline |
Candidate Recommendation | No change. |
CSS Level 2 (Revision 1) outline |
Recommendation |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | 1.5 (1.8) [1] | 8.0 | 7.0 | 1.2 (125) |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.8) [1] | 8.0 | 6.0 | 3.1 |
In browsers previous to Gecko 1.8 (Firefox 1.5) a similar effect can be achieved using Mozilla CSS Extension -moz-outline
.
[1] Firefox includes absolutely positioned elements inside the outline (bug 687311).