From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/css/outline-color/index.html | 122 +++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 files/zh-cn/web/css/outline-color/index.html (limited to 'files/zh-cn/web/css/outline-color') diff --git a/files/zh-cn/web/css/outline-color/index.html b/files/zh-cn/web/css/outline-color/index.html new file mode 100644 index 0000000000..457caab022 --- /dev/null +++ b/files/zh-cn/web/css/outline-color/index.html @@ -0,0 +1,122 @@ +--- +title: outline-color +slug: Web/CSS/outline-color +translation_of: Web/CSS/outline-color +--- +
{{CSSRef}}
+ +

outline-color CSS属性 被用于设置一个元素轮廓的颜色.

+ +
{{EmbedInteractiveExample("pages/css/outline-color.html")}}
+ + + +

大多时候使用{{cssxref("outline")}}而不是 outline-style, outline-width  outline-color会更方便.

+ +

元素轮廓是绘制于元素周围的一条线,位于{{cssxref("border")}}的外围,使元素突出.不像border,轮廓在元素的frame外绘制并且可能与其他元素重叠.而border不会出现这种现象(除非故意).

+ +

语法

+ +
/* <color> values */
+outline-color: #f92525;
+outline-color: rgb(30,222,121);
+outline-color: blue;
+
+/* Keyword value */
+outline-color: invert;
+
+/* Global values */
+outline-color: inherit;
+outline-color: initial;
+outline-color: unset;
+
+ +

outline-color可用以下这些值.

+ +

Values

+ +
+
{{cssxref("<color>")}}
+
轮廓颜色,规则同 <color>.
+
invert
+
反色,用于确认轮廓的显示.注意不是所有浏览器都支持该属性,若不则该属性无效.
+
+ +

正规语法

+ +
{{csssyntax}}
+ +

例子

+ +

HTML

+ +
<p>My outline is blue, as you can see.</p>
+ +

CSS

+ +
p {
+  outline: 2px solid;      /* Set the outline width and style */
+  outline-color: #0000FF;  /* Make the outline blue */
+  margin: 5px;
+}
+ +

{{ EmbedLiveSample('Example') }}

+ +

Accessibility concerns

+ +

Custom focus styles commonly involve making adjustments to the {{cssxref("outline")}} property. If the color of the outline is adjusted, it is important to ensure that the contrast ratio between it and the background the outline is placed over is high enough that people experiencing low vision conditions will be able to perceive it.

+ +

Color contrast ratio is determined by comparing the luminosity of the text and background color values. In order to meet current Web Content Accessibility Guidelines (WCAG), a ratio of 4.5:1 is required for text content and 3:1 for larger text such as headings. Large text is defined as 18.66px and bold or larger, or 24px or larger.

+ + + +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('CSS3 Basic UI', '#outline-color', 'outline-color')}}{{Spec2('CSS3 Basic UI')}}No change.
{{SpecName('CSS3 Transitions', '#animatable-css', 'outline-color')}}{{Spec2('CSS3 Transitions')}}Defines outline-color as animatable.
{{SpecName('CSS2.1', 'ui.html#propdef-outline-color', 'outline-color')}}{{Spec2('CSS2.1')}}Initial definition.
+ +

{{cssinfo}}

+ +

浏览器兼容性

+ +
+ + +

{{Compat("css.properties.outline-color")}}

+
+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf