Advertisement
Guest User

Untitled

a guest
May 25th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. //CSS
  2. #canvas-container {
  3. width: 100%;
  4. text-align:center;
  5. margin:auto;
  6. }
  7. div.fullscreen:-webkit-full-screen {
  8. width: 100%;
  9. height: 100%;
  10. }
  11. div.fullscreen:-moz-full-screen {
  12.  
  13. width: 100%;
  14. height: 100%;
  15. }
  16. //HTML
  17. <div id="canvas-container">
  18. <div class="fullscreen">
  19. <canvas id="layer1" width="800" height="500"
  20. style="position: absolute; z-index: 0; border:3px solid #EE6D00; "></canvas>
  21. <canvas id="layer2" width="800" height="500"
  22. style="position: absolute; z-index: 1; border:3px solid #EE6D00; "></canvas>
  23. <canvas id="layer3" width="800" height="500"
  24. style="position: relative; z-index: 2; border:3px solid #EE6D00; "></canvas>
  25. </div>
  26. </div>
  27. <button class="button" onclick="goFullscreen(); return false">max</button>
  28. //JavaScript
  29. var cn = document.getElementsByClassName("fullscreen");
  30. function goFullscreen() {
  31. // Get the element that we want to take into fullscreen mode
  32.  
  33. // These function will not exist in the browsers that don't support fullscreen mode yet,
  34. // so we'll have to check to see if they're available before calling them.
  35.  
  36. if (cn.mozRequestFullScreen) {
  37. // This is how to go into fullscren mode in Firefox
  38. // Note the "moz" prefix, which is short for Mozilla.
  39. cn.mozRequestFullScreen();
  40.  
  41. } else if (cn.webkitRequestFullScreen) {
  42. // This is how to go into fullscreen mode in Chrome and Safari
  43. // Both of those browsers are based on the Webkit project, hence the same prefix.
  44. cn.webkitRequestFullScreen();
  45.  
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement