/* 选择当前处于全屏模式的body元素 */ body:fullscreen { background-color: black; } /* 选择当前处于全屏模式的div元素 */ div:fullscreen { border: 1px solid red; }
/* 进入全屏模式 */ function enterFullscreen() { if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen(); } else if (document.documentElement.mozRequestFullScreen) { document.documentElement.mozRequestFullScreen(); } else if (document.documentElement.webkitRequestFullscreen) { document.documentElement.webkitRequestFullscreen(); } else if (document.documentElement.msRequestFullscreen) { document.documentElement.msRequestFullscreen(); } } /* 退出全屏模式 */ function exitFullscreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } }
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com