質問

CSS属性のセレクタ は、選考の要素に基づく属性の値です。残念なことに、私は使用して年主としてがん対応していないすべての最新ブラウザ).しかし、思える私はそれらを使えるようにすることに飾すべての外部リンクアイコンを使用し、コード、例えば次のようなもの:

a[href=http] {
    background: url(external-uri);
    padding-left: 12px;
}

上記のコードは無効となります。私の質問は どのような仕組みになっているのか。 いすべて選択 <a> タグが href 属性から始ま "http"?のCSS仕様(リンク先なものを挙げることが可能です。がんを行っています。

(注意:を明らかい使用 class 属性を区別する避けたいことかしないほうがよいと思うのは、HTMLコードで構築されています。すべてのIで編集では、CSSコードです。)

役に立ちましたか?

解決

とCSS2.1、 http://www.w3.org/TR/CSS21/selector.html#attribute-selectors

要旨:

    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ついても明らかにしています。リストのセレクタ, ものの、 の互換性により異なり大き.

ものもありま ビ試験スイート るるるセレクタを作ブラウザを起動します。

など充実した設備でお客様の旅行の例では、

a[href^=http]
{
    background: url(external-uri);
    padding-left: 12px;
}

ています。残念なことに、によってサポートされていないが打ち出されている。-

他のヒント

Anttiの答えは十分な選択アンカーズがhrefの始まり http とぴョご利用CSS2 regex-正規表現の味 属性セレクタはこのように:

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 :なし 疑似クラスセレクタ などの新しい *= 部分文字列の構文 く軽視の内部リンクも始まる http:

a[href^=http]:not([href*="yourdomain.com"])
{
    background: url(external-uri);
    padding-left: 12px;
}

※これは未サポートによる家は、少なくともIE8.げるには、最:P

なお、アンティはどん追加したいと思うかもしれぎず絶対リンクの場合はご自身のドメインかも知れません。 したいフラグとして外部',例えば:

a[href^="http://your.domain.com"]
{
    background: none;
    padding: 0;
}

やんたこ 前の宣言です。

まもりたいのプロトコルの接頭、また地元の文書に"http-info.html"のリンクをご希望される例:

a[href^="http://"]
{
    background: url(external-uri);
    padding-left: 12px;
}

なお、これらの少し複雑な場合、見積もりの値です。これらの作品に、私にとって、IE7.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top