outline-color
åºçº¿
广æ³å¯ç¨
èª 2015å¹´7æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
outline-color CSS 屿§ 被ç¨äºè®¾ç½®ä¸ä¸ªå
ç´ è½®å»çé¢è²ã
å°è¯ä¸ä¸
outline-color: red;
outline-color: #32a1ce;
outline-color: rgba(170, 50, 220, 0.6);
outline-color: hsla(60, 90%, 50%, 0.8);
outline-color: currentcolor;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
This is a box with an outline around it.
</div>
</section>
#example-element {
outline: 0.75em solid;
padding: 0.75em;
width: 80%;
height: 100px;
}
大夿¶å使ç¨outlineè䏿¯ outline-style, outline-width å outline-color伿´æ¹ä¾¿ã
å
ç´ è½®å»æ¯ç»å¶äºå
ç´ å¨å´ç䏿¡çº¿ï¼ä½äº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å¯ç¨ä»¥ä¸è¿äºå¼ã
å¼
å½¢å¼è¯æ³
outline-color =
auto |
<'border-top-color'>
<border-top-color> =
<color> |
<image-1D>
<image-1D> =
<stripes()>
<stripes()> =
stripes( <color-stripe># )
<color-stripe> =
<color> &&
[ <length-percentage> | <flex> ]?
<length-percentage> =
<length> |
<percentage>
示ä¾
>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;
}
Accessibility concerns
Custom focus styles commonly involve making adjustments to the 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.
è§è
| è§è |
|---|
| CSS Basic User Interface Module Level 4 > # outline-color > |
| åå§å¼ | auto |
|---|---|
| éç¨å ç´ | ææå ç´ |
| æ¯å¦æ¯ç»§æ¿å±æ§ | å¦ |
| 计ç®å¼ | For the keyword auto, the computed value is currentcolor. For the color value, if the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0). |
| å¨ç»ç±»å | a color |
æµè§å¨å ¼å®¹æ§
åè§
<color>æ°æ®ç±»å- å
¶ä»ä¸é¢è²æå
³ç屿§ï¼
color,background-color,border-color,text-decoration-color,text-emphasis-color,text-shadow,caret-color, åcolumn-rule-color - Applying color to HTML elements using CSS