aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/css/adjacent_sibling_combinator/index.html
blob: f962949f352b4995bc2f033cd7d77622314cf4eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
title: 隣接兄弟結合子
slug: Web/CSS/Adjacent_sibling_combinator
tags:
  - CSS
  - Reference
  - Selectors
  - セレクター
translation_of: Web/CSS/Adjacent_sibling_combinator
---
<div>{{CSSRef("Selectors")}}</div>

<p><ruby><strong>隣接兄弟結合子</strong><rp> (</rp><rt>adjacent sibling combinator</rt><rp>)</rp></ruby> (<code>+</code>) は2つのセレクターを接続し、同じ親{{DOMxRef("element", "要素")}}の子同士であって、1つ目の要素の<em>直後</em>にある2つ目の要素を選択します。</p>

<pre class="brush: css no-line-numbers">/* 画像の直後に来る段落 */
img + p {
  font-style: bold;
}</pre>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox">直前の要素 + 対象の要素 { <em>スタイルプロパティ</em> }
</pre>

<h2 id="Example" name="Example"></h2>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">li:first-of-type + li {
  color: red;
}
</pre>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;ul&gt;
  &lt;li&gt;One&lt;/li&gt;
  &lt;li&gt;Two!&lt;/li&gt;
  &lt;li&gt;Three&lt;/li&gt;
&lt;/ul&gt;</pre>

<h3 id="Result">Result</h3>

<p>{{EmbedLiveSample("Example", "100%", 100)}}</p>

<h2 id="Specifications" name="Specifications">仕様書</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">仕様書</th>
   <th scope="col">状態</th>
   <th scope="col">備考</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("CSS4 Selectors", "#adjacent-sibling-combinators", "next-sibling combinator")}}</td>
   <td>{{Spec2("CSS4 Selectors")}}</td>
   <td>名前を「次の兄弟」結合子に変更。</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS3 Selectors", "#adjacent-sibling-combinators", "Adjacent sibling combinator")}}</td>
   <td>{{Spec2("CSS3 Selectors")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName("CSS2.1", "selector.html#adjacent-selectors", "Adjacent sibling selectors")}}</td>
   <td>{{Spec2("CSS2.1")}}</td>
   <td>初回定義</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2>

<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>

<p>{{Compat("css.selectors.adjacent_sibling")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/General_sibling_combinator">一般兄弟結合子</a></li>
</ul>