diff options
| author | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-10-26 23:12:35 +0900 |
|---|---|---|
| committer | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-11-03 21:48:56 +0900 |
| commit | e1bb793c6c8afd6558fb3d4767faf4c8b80c59ff (patch) | |
| tree | be462a5b5028d2fd2900c5454c1da01f2b38ac77 /files/ja/web/css/_colon_focus | |
| parent | 0c68616aa46f09d03108f47b71490a4a87517005 (diff) | |
| download | translated-content-e1bb793c6c8afd6558fb3d4767faf4c8b80c59ff.tar.gz translated-content-e1bb793c6c8afd6558fb3d4767faf4c8b80c59ff.tar.bz2 translated-content-e1bb793c6c8afd6558fb3d4767faf4c8b80c59ff.zip | |
:focus 系のセレクターの文書を更新
- 2021/10/25 時点の英語版に同期
Diffstat (limited to 'files/ja/web/css/_colon_focus')
| -rw-r--r-- | files/ja/web/css/_colon_focus/index.md | 141 |
1 files changed, 53 insertions, 88 deletions
diff --git a/files/ja/web/css/_colon_focus/index.md b/files/ja/web/css/_colon_focus/index.md index 01c4077455..840290e034 100644 --- a/files/ja/web/css/_colon_focus/index.md +++ b/files/ja/web/css/_colon_focus/index.md @@ -2,44 +2,46 @@ title: ':focus' slug: 'Web/CSS/:focus' tags: + - ':focus' - CSS - - Layout - - Reference - - Web - - ウェブ - - セレクター - レイアウト - 擬似クラス - - 疑似クラス + - リファレンス + - セレクター + - ウェブ +browser-compat: css.selectors.focus translation_of: 'Web/CSS/:focus' --- -<div>{{CSSRef}}</div> +{{CSSRef}} -<p><strong><code>:focus</code></strong> は <a href="/ja/docs/Web/CSS">CSS</a> の <a href="/ja/docs/Web/CSS/Pseudo-classes" title="Pseudo-classes">擬似クラス</a>で、フォーカスを持っている (フォームの入力のような) 要素を表します。普通はユーザーが要素をクリックやタップをしたり、キーボードの[タブ]キーで選択したりしたときです。</p> +**`:focus`** は [CSS](/ja/docs/Web/CSS) の[擬似クラス](/ja/docs/Web/CSS/Pseudo-classes)で、フォーカスを持っている (フォームの input のような) 要素を表します。普通はユーザーが要素をクリックやタップをしたり、キーボードの <kbd>Tab</kbd> キーで選択したりしたときです。 -<pre class="brush: css no-line-numbers notranslate">/* フォーカスを持つ <input> 要素を選択 */ +```css +/* フォーカスを持つ <input> 要素を選択 */ input:focus { color: red; -}</pre> +} +``` -<div class="blockIndicator note"> -<p><strong>メモ:</strong> この擬似クラスはフォーカスを持つ要素に対してのみ適用されます。フォーカスを持つ要素を<em>含む</em>要素を選択したい場合は、 {{CSSxRef(":focus-within")}} を使用してください。</p> -</div> +> **Note:** この擬似クラスはフォーカスを持つ要素に対してのみ適用されます。フォーカスを持つ要素を*含む*要素を選択したい場合は、{{CSSxRef(":focus-within")}} を使用してください。 -<h2 id="Syntax" name="Syntax">構文</h2> +## 構文 {{CSSSyntax}} -<h2 id="Example" name="Example">例</h2> +<h2 id="Examples">例</h2> -<h3 id="HTML">HTML</h3> +### HTML -<pre class="brush: html no-line-numbers notranslate"><input class="red-input" value="I'll be red when focused."><br> -<input class="blue-input" value="I'll be blue when focused."></pre> +```html +<div><input class="red-input" value="フォーカスで赤くなります。"></div> +<div><input class="blue-input" value="フォーカスで青くなります。"></div> +``` -<h3 id="CSS">CSS</h3> +### CSS -<pre class="brush: css highlight[1, 6] notranslate">.red-input:focus { +```css +.red-input:focus { background: yellow; color: red; } @@ -47,71 +49,34 @@ input:focus { .blue-input:focus { background: yellow; color: blue; -}</pre> - -<h3 id="Result" name="Result">結果</h3> - -<p>{{EmbedLiveSample("Example")}}</p> - -<h2 id="Accessibility_Concerns" name="Accessibility_Concerns">アクセシビリティの考慮事項</h2> - -<p>視覚的なフォーカスインジケーターが、弱視の人々からも見えるように確認してください。これは外光が明るい場所 (太陽の下の屋外など) で画面を使用するすべての人にも利益になります。 <a href="https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html">WCAG 2.1 SC 1.4.11 Non-Text Contrast</a> は、視覚的なフォーカスインジケーターを少なくとも 3:1 にすることを要求しています。</p> - -<ul> - <li>Accessible Visual Focus Indicators: <a href="https://www.deque.com/blog/give-site-focus-tips-designing-usable-focus-indicators/">Give Your Site Some Focus! Tips for Designing Useful and Usable Focus Indicators</a></li> -</ul> - -<h3 id="focus_outline_none"><code>:focus { outline: none; }</code></h3> - -<p><a href="https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html">WCAG 2.1 SC 1.4.11 Non-Text Contrast</a> を満たすフォーカスの輪郭線で置き換えることなく、フォーカスの輪郭線 (視覚的なフォーカスインジケーター) を単に削除しないでください。</p> - -<ul> - <li>Quick Tip: <a href="https://a11yproject.com/posts/never-remove-css-outlines/">Never remove CSS outlines</a></li> -</ul> - -<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("HTML WHATWG", "scripting.html#selector-focus", ":focus")}}</td> - <td>{{Spec2("HTML WHATWG")}}</td> - <td>HTML に依存した意味論を定義。</td> - </tr> - <tr> - <td>{{SpecName("CSS4 Selectors", "#focus-pseudo", ":focus")}}</td> - <td>{{Spec2("CSS4 Selectors")}}</td> - <td>変更なし。</td> - </tr> - <tr> - <td>{{SpecName("CSS3 Selectors", "#the-user-action-pseudo-classes-hover-act", ":focus")}}</td> - <td>{{Spec2("CSS3 Selectors")}}</td> - <td>変更なし。</td> - </tr> - <tr> - <td>{{SpecName("CSS2.1", "selector.html#dynamic-pseudo-classes", ":focus")}}</td> - <td>{{Spec2("CSS2.1")}}</td> - <td>初回定義。</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> - -<div> -<p>{{Compat("css.selectors.focus")}}</p> -</div> - -<h2 id="See_also" name="See_also">関連情報</h2> - -<ul> - <li>{{CSSxRef(":focus-visible")}} {{Experimental_Inline}}</li> - <li>{{CSSxRef(":focus-within")}}</li> -</ul> +} +``` + +### 結果 + +{{EmbedLiveSample("Examples")}} + +## アクセシビリティの考慮 + +視覚的なフォーカスインジケーターが、弱視の人々からも見えるように確認してください。これは外光が明るい場所 (太陽の下の屋外など) で画面を使用するすべての人にも利益になります。 [WCAG 2.1 SC 1.4.11 Non-Text Contrast](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html) は、視覚的なフォーカスインジケーターを少なくとも 3:1 にすることを要求しています。 + +- Accessible Visual Focus Indicators: [Give Your Site Some Focus! Tips for Designing Useful and Usable Focus Indicators](https://www.deque.com/blog/give-site-focus-tips-designing-usable-focus-indicators/) + +### `:focus { outline: none; }` + +[WCAG 2.1 SC 1.4.11 Non-Text Contrast](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html) を満たすフォーカスの輪郭線で置き換えることなしに、フォーカスの輪郭線 (視覚的なフォーカスインジケーター) を削除しないでください。 + +- Quick Tip: [Never remove CSS outlines](https://a11yproject.com/posts/never-remove-css-outlines/) + +## 仕様書 + +{{Specifications}} + +## ブラウザーの互換性 + +{{Compat}} + +## 関連情報 + +- {{CSSxRef(":focus-visible")}} +- {{CSSxRef(":focus-within")}} |
