Antti 的答案足以选择其 href 以http开头的锚点,并在可用的 CSS2 regex-esque属性选择器上提供完美的概要,如下所示:
Attribute selectors may match in four ways:
[att]
Match when the element sets the "att" attribute, whatever the value of the attribute.
[att=val]
Match when the element's "att" attribute value is exactly "val".
[att~=val]
Match when the element's "att" attribute value is a space-separated list of
"words", one of which is exactly "val". If this selector is used, the words in the
value must not contain spaces (since they are separated by spaces).
[att|=val]
Match when the element's "att" attribute value is a hyphen-separated list of
"words", beginning with "val". The match always starts at the beginning of the
attribute value. This is primarily intended to allow language subcode matches
(e.g., the "lang" attribute in HTML) as described in RFC 3066 ([RFC3066]).
但是,这是使用新的CSS3 :not伪类选择器以及新的*=子字符串语法来选择所有传出链接的适当的更新方法,以确保它忽略任何可能仍以http开头的内部链接:
a[href^=http]:not([href*="yourdomain.com"])
{
background: url(external-uri);
padding-left: 12px;
}
*请注意,IE 不支持此功能,至少 IE8 不支持。谢谢,IE,你是最好的:P