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
|
---
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>
{{csssyntax}}
<h2 id="例子">例子</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: 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>
</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 > h1 {
color: red;
}
#fullscreen:-ms-fullscreen > h1 {
color: red;
}
#fullscreen:-webkit-full-screen > h1 {
color: red;
}
#fullscreen:-moz-full-screen > p {
color: DarkRed;
}
#fullscreen:-ms-fullscreen > p {
color: DarkRed;
}
#fullscreen:-webkit-full-screen > p {
color: DarkRed;
}
#fullscreen:-moz-full-screen > button {
display: none;
}
#fullscreen:-ms-fullscreen > button {
display: none;
}
#fullscreen:-webkit-full-screen > 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 > h1 {
color: red;
}
#fullscreen:fullscreen > p {
color: DarkRed;
}
#fullscreen:fullscreen > 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>
{{Compat("css.selectors.fullscreen")}}
<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>
|