aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/css/_colon_first-child
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/css/_colon_first-child
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/css/_colon_first-child')
-rw-r--r--files/ja/web/css/_colon_first-child/index.html135
1 files changed, 135 insertions, 0 deletions
diff --git a/files/ja/web/css/_colon_first-child/index.html b/files/ja/web/css/_colon_first-child/index.html
new file mode 100644
index 0000000000..a0377e61a9
--- /dev/null
+++ b/files/ja/web/css/_colon_first-child/index.html
@@ -0,0 +1,135 @@
+---
+title: ':first-child'
+slug: 'Web/CSS/:first-child'
+tags:
+ - CSS
+ - Layout
+ - Pseudo-class
+ - Reference
+ - Selector
+ - Web
+translation_of: 'Web/CSS/:first-child'
+---
+<div>{{CSSRef}}</div>
+
+<p><strong><code>:first-child</code></strong> は <a href="/ja/docs/Web/CSS">CSS</a> の<a href="/ja/docs/CSS/Pseudo-classes" title="Pseudo-classes">擬似クラス</a>で、兄弟要素のグループの中で最初の要素を表します。</p>
+
+<pre class="brush: css no-line-numbers notranslate">/* 兄弟要素の中で最初の &lt;p&gt; を
+ すべてを選択 */
+p:first-child {
+ color: lime;
+}</pre>
+
+<div class="note">
+<p><strong>注:</strong> 最初の定義では、親のある要素のみが選択されていました。 Selectors Level 4 の初期に、これは必要なくなりました。</p>
+</div>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox notranslate">{{csssyntax}}
+</pre>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<h3 id="Basic_example" name="Basic_example">基本的な例</h3>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html notranslate">&lt;div&gt;
+ &lt;p&gt;This text is selected!&lt;/p&gt;
+ &lt;p&gt;This text isn't selected.&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+ &lt;h2&gt;This text isn't selected: it's not a `p`.&lt;/h2&gt;
+ &lt;p&gt;This text isn't selected.&lt;/p&gt;
+&lt;/div&gt;
+</pre>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css notranslate">p:first-child {
+ color: lime;
+ background-color: black;
+ padding: 5px;
+}
+</pre>
+
+<h4 id="Result" name="Result">結果</h4>
+
+<p><span>{{EmbedLiveSample('Basic_example', 500, 200)}}</span></p>
+
+<h3 id="Styling_a_list" name="Styling_a_list">リストのスタイル付け</h3>
+
+<h4 id="HTML_2">HTML</h4>
+
+<pre class="brush: html notranslate">&lt;ul&gt;
+ &lt;li&gt;Item 1&lt;/li&gt;
+ &lt;li&gt;Item 2&lt;/li&gt;
+ &lt;li&gt;Item 3
+ &lt;ul&gt;
+ &lt;li&gt;Item 3.1&lt;/li&gt;
+ &lt;li&gt;Item 3.2&lt;/li&gt;
+ &lt;li&gt;Item 3.3&lt;/li&gt;
+ &lt;/ul&gt;
+ &lt;/li&gt;
+&lt;/ul&gt;</pre>
+
+<h4 id="CSS_2">CSS</h4>
+
+<pre class="brush: css notranslate">ul li {
+ color: blue;
+}
+
+ul li:first-child {
+ color: red;
+ font-weight: bold;
+}</pre>
+
+<h4 id="Result_2" name="Result_2">結果</h4>
+
+<p>{{EmbedLiveSample('Styling_a_list')}}</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', '#first-child-pseudo', ':first-child')}}</td>
+ <td>{{Spec2('CSS4 Selectors')}}</td>
+ <td>選択する要素に親を必要としないようにした。</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Selectors', '#first-child-pseudo', ':first-child')}}</td>
+ <td>{{Spec2('CSS3 Selectors')}}</td>
+ <td>変更なし。</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS2.1', 'selector.html#first-child', ':first-child')}}</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.first-child")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li>{{CSSxRef(":-moz-first-node")}} {{Non-standard_Inline}}</li>
+ <li>{{CSSxRef(":first-of-type")}}</li>
+ <li>{{CSSxRef(":last-child")}}</li>
+ <li>{{CSSxRef(":nth-child", ":nth-child()")}}</li>
+</ul>