Created
March 16, 2020 04:34
-
-
Save okumurakengo/8547ef532d51cf1c9b1828aeefe35ed9 to your computer and use it in GitHub Desktop.
fullscreen style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
#my-text { | |
color: #faa; | |
} | |
#my-text:fullscreen { | |
color: #afa; | |
} | |
::backdrop { | |
background: rgb(111, 150, 255); | |
} | |
</style> | |
<button | |
onclick="activateFullscreen(document.getElementById('my-text'));" | |
> | |
Fullscreen #my-text! | |
</button> | |
<div id="my-text"> | |
<h1>Hello world</h1> | |
<span>Lorem ipsum dolor sit amet.</span> | |
</div> | |
<script> | |
function activateFullscreen(element) { | |
if(element.requestFullscreen) { | |
element.requestFullscreen(); // W3C spec | |
} | |
else if (element.mozRequestFullScreen) { | |
element.mozRequestFullScreen(); // Firefox | |
} | |
else if (element.webkitRequestFullscreen) { | |
element.webkitRequestFullscreen(); // Safari | |
} | |
else if(element.msRequestFullscreen) { | |
element.msRequestFullscreen(); // IE/Edge | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment