:fullscreen 伪类选择并设置以全屏模式显示的元素的样式。
:fullscreen 选择器在进入全屏模式时起作用。
:fullscreen 选择器与 -webkit-、-moz-、-ms- 前缀配合使用,以实现最大的浏览器兼容性。
语法
:fullscreen {
css declarations;
}
在以下示例中,单击按钮以全屏模式查看元素。
:fullscreen 选择器的例子:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.example {
padding: 10px;
height: 200px;
width: 95%;
background-color: #1c87c9;
}
.example p {
visibility: hidden;
text-align: center;
color: #eeeeee;
font-size: 3em;
}
.example:-webkit-full-screen {
background-color: #8ebf42;
width: 100vw;
height: 100vh;
}
.example:-webkit-full-screen p {
visibility: visible;
}
.example:-moz-full-screen {
background-color: #8ebf42;
width: 100vw;
height: 100vh;
}
.example:-moz-full-screen p {
visibility: visible;
}
.example:-ms-fullscreen {
background-color: #8ebf42;
width: 100vw;
height: 100vh;
}
.example:-ms-fullscreen p {
visibility: visible;
}
.example:fullscreen {
background-color: #8ebf42;
width: 100vw;
height: 100vh;
}
.example:fullscreen p {
visibility: visible;
}
</style>
</head>
<body>
<h2>:fullscreen pseudo-class example</h2>
<div class="container">
<div class="example" id="example">
<p>Fullscreen mode</p>
</div>
<br>
<button onclick="var el=document.getElementById('example'); el.webkitRequestFullscreen();">Click here</button>
</div>
</body>
</html>
日期:2020-06-02 22:14:33 来源:oir作者:oir
