Guest User

Untitled

a guest
Dec 15th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <meta name="viewport" content="width=device-width, user-scalable=no" />
  6. <style>
  7. html {
  8. height: 100%;
  9. width: 100%;
  10. }
  11. body {
  12. height: 2000px;
  13. width: 100%;
  14. margin: 0px;
  15. padding: 0px;
  16. }
  17.  
  18. div.bar {
  19. width: 20px;
  20. top: 0px;
  21. box-sizing: border-box;
  22. border: 3px solid purple;
  23. }
  24.  
  25. .fixedpercent {
  26. position: fixed;
  27. height: 100%;
  28. background-color: lightsteelblue;
  29. }
  30.  
  31. .fixedvh {
  32. position: fixed;
  33. height: 100vh;
  34. background-color: lightskyblue;
  35. }
  36.  
  37. .abspercent {
  38. position: absolute;
  39. height: 100%;
  40. background-color: darksalmon;
  41. }
  42.  
  43. .absvh {
  44. position:absolute;
  45. height: 100vh;
  46. background-color: coral;
  47. }
  48.  
  49. .textfixed {
  50. width: 600px;
  51. height: 20px;
  52. padding: 0px 20px;
  53. transform: rotate(90deg);
  54. transform-origin: left bottom 0;
  55. }
  56.  
  57. .textabs {
  58. width: 600px;
  59. height: 20px;
  60. padding: 0px 120px;
  61. transform: rotate(90deg);
  62. transform-origin: left bottom 0;
  63. }
  64.  
  65. #console {
  66. position: fixed;
  67. top: 10px;
  68. left: 10px;
  69. }
  70.  
  71. #fixedbottom {
  72. position: fixed;
  73. bottom: 0;
  74. left: 0;
  75. width: 50%;
  76. height: 25px;
  77. background-color: green;
  78. }
  79. </style>
  80. <script>
  81. let count = 0;
  82. function resized() {
  83. document.getElementById("innerHight").textContent = window.innerHeight;
  84. document.getElementById("clientHeight").textContent = document.documentElement.clientHeight;
  85. document.getElementById("count").textContent = ++count;
  86. }
  87. var fullscreen = false;
  88. addEventListener("load", function() {
  89. document.documentElement.addEventListener("click", function() {
  90. if (fullscreen)
  91. document.webkitExitFullscreen();
  92. else
  93. document.documentElement.webkitRequestFullscreen();
  94.  
  95. fullscreen = !fullscreen;
  96. });
  97. });
  98. </script>
  99. </head>
  100.  
  101. <body onresize="resized()">
  102.  
  103. <div style="right: 0px" class="bar fixedpercent"><div class="textfixed">percentage-based position:fixed</div></div>
  104. <div style="right: 25px" class="bar fixedvh"><div class="textfixed">viewport-unit position:fixed</div></div>
  105. <div style="right: 50px" class="bar abspercent"><div class="textabs">percentage-based position:absolute</div></div>
  106. <div style="right: 75px" class="bar absvh"><div class="textabs">viewport-unit position:absolute</div></div>
  107. <div id="console">
  108. <dl>
  109. <td>window.innerHeight</td><dd id="innerHight"></dd>
  110. <td>documentElement.clientHeight</td><dd id="clientHeight"></dd>
  111. <td>Event count</td><dd id="count"></dd>
  112. </dl>
  113. </div>
  114. <div id="fixedbottom"></div>
  115. </body>
  116. </html>
Add Comment
Please, Sign In to add comment