问题
On one of my applications I noticed Chrome was automatically setting link colors as the color "-webkit-link" via this rule:
/* Not set by my CSS stylesheet */
a:-webkit-any-link {
color: -webkit-link;
text-decoration: underline;
cursor: auto;
}
It is much easier for me to remember a default link color as -webkit-link than a hex code.
I tried setting the color of text wrapped in a p tag and a div tag and this seemed to work fine on Codepen.
div, p { color: -webkit-link; }
Is "-webkit-color" a valid color for wherever a color is relevant? (I could test every possible circumstance for which color is valid but I don't have time). For example, would this rule give a "link blue" border color?
div { border: 2px solid -webkit-link; }
or this rule set a linear-gradient with "link blue"?
div { background-image: linear-gradient(135deg, red 60%, -webkit-link 60%); }
or this rule set a box-shadow with a "link blue" color?
div { box-shadow: inset 2px 2px 2px 4px -webkit-link; }
and endless others which use color?
回答1:
No, -webkit-link is not a valid color.
While it does work anywhere you can use a color, it is not in any standard, and neither Apple nor any of the maintainers of the Blink engine have any obligation to keep it working. There's no guarantee.
In addition, it doesn't work in other browsers. For Firefox, there's -moz-hyperlinkText, but the same disclaimers apply.
(MDN has a page where the Mozilla colors are described, but there doesn't seem to be a similar official page for Webkit. Let that be a warning.)
来源:https://stackoverflow.com/questions/37552441/is-webkit-link-a-valid-color-for-any-html-element-or-css-property-for-which-col