From 81e89736914413e2b1807f7142eef313449c27ce Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Thu, 6 Jan 2022 08:56:29 +0900 Subject: セレクター結合子の記事を変換準備 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ja/web/css/general_sibling_combinator/index.md | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 files/ja/web/css/general_sibling_combinator/index.md (limited to 'files/ja/web/css/general_sibling_combinator/index.md') diff --git a/files/ja/web/css/general_sibling_combinator/index.md b/files/ja/web/css/general_sibling_combinator/index.md new file mode 100644 index 0000000000..22b97dc75c --- /dev/null +++ b/files/ja/web/css/general_sibling_combinator/index.md @@ -0,0 +1,84 @@ +--- +title: 一般兄弟結合子 +slug: Web/CSS/General_sibling_combinator +tags: + - CSS + - Reference + - Selectors + - セレクター +translation_of: Web/CSS/General_sibling_combinator +--- +
{{CSSRef("Selectors")}}
+ +

一般兄弟結合子 (general sibling combinator, ~) は2個のセレクターを結びつけます。右側のセレクタで選択される要素のうち、次の条件をともにみたすものを選択します。

+ +

まず、右側のセレクタで選択される要素が、左側のセレクタで選択される要素より後に現れることです。(直後である必要はありません)

+ +

もうひとつは、これらの要素が同じ親要素({{Glossary("element", "要素")}})をもつことです。

+ +
/* 任意の画像の兄弟で、
+   その画像より後方にある段落 */
+img ~ p {
+  color: red;
+}
+ +

構文

+ +
先行する要素 ~ 選択される要素 { スタイルプロパティ }
+
+ +

+ +

CSS

+ +
p ~ span {
+  color: red;
+}
+ +

HTML

+ +
<span>This is not red.</span>
+<p>Here is a paragraph.</p>
+<code>Here is some code.</code>
+<span>And here is a red span!</span>
+<code>More code...</code>
+<span>And this is a red span!</span>
+
+ +

結果

+ +

{{EmbedLiveSample("Example", "100%", 120)}}

+ +

仕様書

+ + + + + + + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName("CSS4 Selectors", "#general-sibling-combinators", "subsequent-sibling combinator")}}{{Spec2("CSS4 Selectors")}}名前を"subsequent-sibling combinator"に変更。
{{SpecName("CSS3 Selectors", "#general-sibling-combinators", "general sibling combinator")}}{{Spec2("CSS3 Selectors")}}初回定義
+ +

ブラウザーの対応

+ +

{{Compat("css.selectors.general_sibling")}}

+ +

関連情報

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