--- title: ':fullscreen' slug: 'Web/CSS/:fullscreen' tags: - CSS - Full-screen - Full-screen API - Fullscreen API - Pseudo-class - Reference - Selector - fullscreen - screen translation_of: 'Web/CSS/:fullscreen' --- <div>{{CSSRef}}</div> <p><span class="seoSummary"><strong><code>:fullscreen</code></strong> は <a href="/ja/docs/Web/CSS">CSS</a> の <a href="/ja/docs/CSS/Pseudo-classes">擬似クラス</a>で、現在全画面モードにあるすべての要素に一致します。複数の要素が全画面モードにある場合は、それらすべてを選択します。</span></p> <h2 id="Syntax" name="Syntax">構文</h2> {{csssyntax}} <h2 id="Usage_notes" name="Usage_notes">使用上のメモ</h2> <p><code>:fullscreen</code> 擬似クラスにより、要素が全画面と従来の表示の間を行き来した場合に、コンテンツの寸法、スタイル、レイアウトをスタイルシートで自動的に調整することができます。</p> <h2 id="Examples" name="Examples">例</h2> <p>この例では、文書が全画面モードであるかどうかによってボタンの色が変化します。これは JavaScript でスタイルの変更を適用せずに行われます。</p> <h3 id="HTML">HTML</h3> <p>ページの HTML は次のようなものです。</p> <pre class="brush: html notranslate"><h1>MDN Web Docs Demo: :fullscreen pseudo-class</h1> <p>This demo uses the <code>:fullscreen</code> pseudo-class to automatically change the style of a button used to toggle full-screen mode on and off, entirely using CSS.</p> <button id="fs-toggle">Toggle Fullscreen</button></pre> <p><code>"fs-toggle"</code> の ID を持った {{HTMLElement("button")}} が、文書が全画面モードであるかどうかによって淡い赤と淡い緑の間で変化します。</p> <h3 id="CSS">CSS</h3> <p>魔法は CSS で起こります。ここでは二つの規則があります。最初のものは要素が全画面状態でない場合に「Toggle Full-screen Mode」ボタンの色の背景を設定します。鍵になるのは <code>:not(:fullscreen)</code> を使用していることで、 <code>:fullscreen</code> 擬似クラスが適用されない要素を探します。</p> <pre class="brush: css notranslate">#fs-toggle:not(:fullscreen) { background-color: #afa; } </pre> <p>文書が全画面モードで<em>ある</em>場合、代わりに次の CSS が適用され、背景色に淡い赤の影を設定します。</p> <pre class="brush: css notranslate">#fs-toggle:fullscreen { background-color: #faa; }</pre> <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('Fullscreen', '#:fullscreen-pseudo-class', ':fullscreen')}}</td> <td>{{Spec2('Fullscreen')}}</td> <td>初回定義</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> <div> <p>{{Compat("css.selectors.fullscreen")}}</p> </div> <h2 id="See_also" name="See_also">関連情報</h2> <ul> <li><a href="/ja/docs/Web/API/Fullscreen_API">全画面 API</a></li> <li><a href="/ja/docs/Web/API/Fullscreen_API/Guide">全画面 API のガイド</a></li> <li>{{cssxref(":not")}}</li> <li>{{cssxref("::backdrop")}}</li> <li>DOM API: {{ domxref("Element.requestFullscreen()") }}, {{ domxref("Document.exitFullscreen()") }}, {{ domxref("Document.fullscreenElement") }}</li> <li>{{HTMLAttrXRef("allowfullscreen", "iframe")}} 属性</li> </ul>