aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_fullscreen/index.html
blob: fb793fa10999356efa240fb9b36061e79d7abc50 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
---
title: ':fullscreen'
slug: 'Web/CSS/:fullscreen'
tags:
  - CSS
  - CSS Pseudo-class
  - Experimental
  - Full-screen
  - Reference
translation_of: 'Web/CSS/:fullscreen'
---
<div>{{CSSRef}}{{SeeCompatTable}}</div>

<h2 id="总结">总结</h2>

<p><code><font face="Open Sans, Arial, sans-serif">css伪类</font>:fullscreen应用于当前处于全屏显示模式的元素。</code> 它不仅仅选择顶级元素,还包括所有已显示的栈内元素。</p>

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

<h2 id="语法">语法</h2>

<pre class="syntaxbox">{{csssyntax}}</pre>

<h2 id="例子">例子</h2>

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

<pre class="brush: html">&lt;div id="fullscreen"&gt;
  &lt;h1&gt;:fullscreen Demo&lt;/h1&gt;
  &lt;p&gt; This will become a big red text when on fullscreen.&lt;/p&gt;
  &lt;button id="fullscreen-button"&gt;Enter Fullscreen&lt;/button&gt;
&lt;/div&gt;
</pre>

<div class="hidden">
<h3 id="Javascript">Javascript</h3>

<pre class="brush: js">var fullscreenButton = document.getElementById("fullscreen-button");
var fullscreenDiv    = document.getElementById("fullscreen");
var fullscreenFunc   = fullscreenDiv.requestFullscreen;
if (!fullscreenFunc) {
  ['mozRequestFullScreen',
   'msRequestFullscreen',
   'webkitRequestFullScreen'].forEach(function (req) {
     fullscreenFunc = fullscreenFunc || fullscreenDiv[req];
   });
}
function enterFullscreen() {
  fullscreenFunc.call(fullscreenDiv);
}
fullscreenButton.addEventListener('click', enterFullscreen);
</pre>

<h3 id="Browser-Specific_CSS">Browser-Specific CSS</h3>

<pre class="brush: css">#fullscreen:-moz-full-screen {
  padding: 42px;
  background-color: pink;
  border:2px solid #f00;
  font-size: 200%;
}
#fullscreen:-ms-fullscreen {
  padding: 42px;
  background-color: pink;
  border:2px solid #f00;
  font-size: 200%;
}
#fullscreen:-webkit-full-screen {
  padding: 42px;
  background-color: pink;
  border:2px solid #f00;
  font-size: 200%;
}

#fullscreen:-moz-full-screen &gt; h1 {
  color: red;
}
#fullscreen:-ms-fullscreen &gt; h1 {
  color: red;
}
#fullscreen:-webkit-full-screen &gt; h1 {
  color: red;
}

#fullscreen:-moz-full-screen &gt; p {
  color: DarkRed;
}
#fullscreen:-ms-fullscreen &gt; p {
  color: DarkRed;
}
#fullscreen:-webkit-full-screen &gt; p {
  color: DarkRed;
}

#fullscreen:-moz-full-screen &gt; button {
  display: none;
}
#fullscreen:-ms-fullscreen &gt; button {
  display: none;
}
#fullscreen:-webkit-full-screen &gt; button {
  display: none;
}
</pre>
</div>

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

<pre class="brush: css">#fullscreen:fullscreen {
  padding: 42px;
  background-color: pink;
  border:2px solid #f00;
  font-size: 200%;
}

#fullscreen:fullscreen &gt; h1 {
  color: red;
}

#fullscreen:fullscreen &gt; p {
  color: DarkRed;
}

#fullscreen:fullscreen &gt; button {
  display: none;
}
</pre>

<h3 id="结果">结果</h3>

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

<p>{{ EmbedLiveSample('Example','80%','200px') }}</p>

<h2 id="特点">特点</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>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>特性</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>
    <p>基本支持</p>
   </td>
   <td>15.0 {{property_prefix("-webkit")}}<sup>[1]</sup></td>
   <td>12</td>
   <td>{{CompatGeckoDesktop("9.0")}}{{property_prefix("-moz")}}<sup>[1]</sup><br>
    {{CompatGeckoDesktop("47.0")}}<sup>[2]</sup></td>
   <td>11 {{property_prefix("-ms")}}<sup>[3]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>6.0 {{property_prefix("-webkit")}}<sup>[1]</sup></td>
  </tr>
  <tr>
   <td>全屏下选取所有元素</td>
   <td>{{CompatUnknown}}</td>
   <td>12</td>
   <td>{{CompatGeckoDesktop(43)}}</td>
   <td>11</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>特性</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>基本支持</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("9.0")}}<br>
    {{CompatGeckoDesktop("47.0")}}<sup>[2]</sup></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td>全屏下选取所有元素</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("43")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Webkit和Gecko前缀版本在<em>full</em><em>screen</em>之间带有破折号, 但W3C标准使用一个单词:<code>:fullscreen</code>, <code>:-webkit-full-screen</code>, <code>:-moz-full-screen</code>.</p>

<p>[2] Gecko 47.0 {{geckoRelease("47.0")}} 通过参数<code>full-screen-api.unprefix.enabled使用</code>不带前缀的伪类, 默认为false.</p>

<p>[3] Internet Explorer使用前缀<code>-ms,但在</code><em>full</em><em>screen</em>之间没有破折号<code>:-ms-fullscreen</code>.</p>

<h2 id="再看看">再看看</h2>

<ul>
 <li>{{cssxref("::backdrop")}}</li>
 <li><a href="/en-US/docs/Web/API/Fullscreen_API">Using full-screen mode</a></li>
 <li>{{ domxref("Element.requestFullscreen()") }}</li>
 <li>{{ domxref("Document.exitFullscreen()") }}</li>
 <li>{{ domxref("Document.fullscreen") }}</li>
 <li>{{ domxref("Document.fullscreenElement") }}</li>
 <li>{{HTMLAttrXRef("allowfullscreen", "iframe")}}</li>
 <li>{{cssxref(":-moz-full-screen-ancestor")}}</li>
</ul>