--- title: outline-style slug: Web/CSS/outline-style tags: - outline-style translation_of: Web/CSS/outline-style ---
outline-style
CSS 属性被用于设置一个元素轮廓的样式。
元素轮廓是绘制于元素周围的一条线,位于{{cssxref("border")}}的外围,使元素突出
大多时候使用{{cssxref("outline")}}而不是 outline-style
, outline-width 和
outline-color
会更方便.
{{cssinfo}}
/* 关键字 值 */ outline-style: auto; outline-style: none; outline-style: dotted; outline-style: dashed; outline-style: solid; outline-style: double; outline-style: groove; outline-style: ridge; outline-style: inset; outline-style: outset; /* 全局 值*/ outline-style: inherit; outline-style: initial; outline-style: unset;
<br-style>
可为以下这些值:
0
). groove相反
: 轮廓呈凸起状. inset相反
: 轮廓呈突出状.dotted
和 dashed
<div> <div class="dotted"> <p class="dashed">Outline Demo</p> </div> </div>
.dotted { outline-style: dotted; /* 于 "outline: dotted"等价 */ } .dashed { outline-style: dashed; } /* 让效果更清楚 */ * { outline-width: 10px; padding: 15px; }
{{ EmbedLiveSample('Example_1_-_dotted_and_dashed') }}
solid
和 double
<div> <div class="solid"> <p class="double">Outline Demo</p> </div> </div>
.solid { outline-style: solid; } .double { outline-style: double; } /* 让效果更清楚 */ * { outline-width: 10px; padding: 15px; }
{{ EmbedLiveSample('Example_2_-_solid_and_double') }}
groove
和 ridge
<div> <div class="groove"> <p class="ridge">Outline Demo</p> </div> </div>
.groove { outline-style: groove; } .ridge { outline-style: ridge; } /* 让效果更清楚 */ * { outline-width: 10px; padding: 15px; }
{{ EmbedLiveSample('Example_3_-_groove_and_ridge') }}
inset
和 outset
<div> <div class="inset"> <p class="outset">Outline Demo</p> </div> </div>
.inset { outline-style: inset; } .outset { outline-style: outset; } /* 让效果更清楚 */ * { outline-width: 10px; padding: 15px; }
{{ EmbedLiveSample('Example_4_-_inset_and_outset') }}
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS3 Basic UI', '#outline-style', 'outline-style')}} | {{Spec2('CSS3 Basic UI')}} | Added auto value |
{{SpecName('CSS2.1', 'ui.html#propdef-outline-style', 'outline-style')}} | {{Spec2('CSS2.1')}} | Initial definition |
{{Compat("css.properties.outline-style")}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 1.0 | {{CompatVersionUnknown}} | 1.5 (1.8)[1] | 8.0 | 7.0 | 1.2 (125) |
auto |
{{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 2.1 | {{CompatVersionUnknown}} | {{CompatGeckoMobile("46")}} | 10 | 12 | 3.2 |
auto |
{{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] Gecko 1.8及以前 (Firefox 1.5) 该效果可用Mozilla CSS Extension 实现{{Cssxref("-moz-outline-style")}}.