--- title: ':fullscreen' slug: 'Web/CSS/:fullscreen' tags: - CSS - CSS Pseudo-class - Experimental - Full-screen - Reference translation_of: 'Web/CSS/:fullscreen' ---
{{CSSRef}}{{SeeCompatTable}}

总结

css伪类:fullscreen应用于当前处于全屏显示模式的元素。 它不仅仅选择顶级元素,还包括所有已显示的栈内元素。

W3C标准使用不带破折号的单词:fullscreen,但Webkit和Gecko应用接口各自使用前缀带有破折号的变量::-webkit-full-screen 和:-moz-full-screen。微软的Edge和Internet Explorer各自使用标准语法::fullscreen:-ms-fullscreen。

语法

{{csssyntax}}

例子

HTML

<div id="fullscreen">
  <h1>:fullscreen Demo</h1>
  <p> This will become a big red text when on fullscreen.</p>
  <button id="fullscreen-button">Enter Fullscreen</button>
</div>

CSS

#fullscreen:fullscreen {
  padding: 42px;
  background-color: pink;
  border:2px solid #f00;
  font-size: 200%;
}

#fullscreen:fullscreen > h1 {
  color: red;
}

#fullscreen:fullscreen > p {
  color: DarkRed;
}

#fullscreen:fullscreen > button {
  display: none;
}

结果

{{ LiveSampleLink('Example', "(If the 'Enter Fullscreen' button doesn't work, try here)") }}

{{ EmbedLiveSample('Example','80%','200px') }}

特点

特点 情况 评论
{{SpecName('Fullscreen', '#:fullscreen-pseudo-class', ':fullscreen')}} {{Spec2('Fullscreen')}} Initial definition

浏览器兼容性

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

再看看