Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link rel="stylesheet" href="style.css">
  6. </head>
  7. <body>
  8. <div class="wrapper">
  9. <img class="myImg" src="untitled.png" alt="Mooi plaatje Versie 1.0<br>Made by:<br>Ticho Plug" width="300" height="200">
  10. <img class="myImg" src="mooi.png" alt="Mooi plaatje Versie 2.0<br>Made by:<br>Ticho Plug" width="300" height="200">
  11. <img class="myImg" src="mooi2.png" alt="Mooi plaatje Versie 3.0<br>Made by:<br>Ticho Plug" width="300" height="200">
  12. </div>
  13. <!-- The Modal -->
  14. <div id="myModal" class="modal">
  15. <span class="close">&times;</span>
  16. <img class="modal-content" id="img">
  17. <div id="caption"></div>
  18. </div>
  19.  
  20. <script src="script.js" charset="utf-8"></script>
  21.  
  22. </body>
  23. </html>
  24.  
  25.  
  26. body {font-family: Arial, Helvetica, sans-serif;}
  27.  
  28. .myImg {
  29. border-radius: 5px;
  30. cursor: pointer;
  31. transition: 0.3s;
  32. }
  33.  
  34.  
  35.  
  36. .myImg:hover {opacity: 0.7;}
  37.  
  38. .wrapper{
  39. margin-top: auto;
  40. margin-bottom: auto;
  41. }
  42.  
  43. /* The Modal (background) */
  44. .modal {
  45. display: none; /* Hidden by default */
  46. position: fixed; /* Stay in place */
  47. z-index: 1; /* Sit on top */
  48. padding-top: 100px; /* Location of the box */
  49. left: 0;
  50. top: 0;
  51. width: 100%; /* Full width */
  52. height: 100%; /* Full height */
  53. overflow: auto; /* Enable scroll if needed */
  54. background-color: rgb(0,0,0); /* Fallback color */
  55. background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
  56. }
  57.  
  58. /* Modal Content (image) */
  59. .modal-content {
  60. margin: auto;
  61. display: block;
  62. width: 80%;
  63. max-width: 700px;
  64. }
  65.  
  66. /* Caption of Modal Image */
  67. #caption {
  68. margin: auto;
  69. display: block;
  70. width: 80%;
  71. max-width: 700px;
  72. text-align: center;
  73. color: #ccc;
  74. padding: 10px 0;
  75. height: 150px;
  76. }
  77.  
  78. /* Add Animation */
  79. .modal-content, #caption {
  80. -webkit-animation-name: zoom;
  81. -webkit-animation-duration: 0.6s;
  82. animation-name: zoom;
  83. animation-duration: 0.6s;
  84. }
  85.  
  86. @-webkit-keyframes zoom {
  87. from {-webkit-transform:scale(0)}
  88. to {-webkit-transform:scale(1)}
  89. }
  90.  
  91. @keyframes zoom {
  92. from {transform:scale(0)}
  93. to {transform:scale(1)}
  94. }
  95.  
  96. /* The Close Button */
  97. .close {
  98. position: absolute;
  99. top: 15px;
  100. right: 35px;
  101. color: #f1f1f1;
  102. font-size: 40px;
  103. font-weight: bold;
  104. transition: 0.3s;
  105. }
  106.  
  107. .close:hover,
  108. .close:focus {
  109. color: #bbb;
  110. text-decoration: none;
  111. cursor: pointer;
  112. }
  113.  
  114. /* 100% Image Width on Smaller Screens */
  115. @media only screen and (max-width: 700px){
  116. .modal-content {
  117. width: 100%;
  118. }
  119. }
  120.  
  121. // Get the modal
  122. var modal = document.getElementById('myModal');
  123.  
  124. // Get the image and insert it inside the modal - use its "alt" text as a caption
  125. var img = document.getElementsByClassName('myImg');
  126. var modalImg = document.getElementById("img");
  127. var captionText = document.getElementById("caption");
  128. for (var i = 0; i < img.length; i++) {
  129. img[i].onclick = function(){
  130. modal.style.display = "block";
  131. modalImg.src = this.src;
  132. captionText.innerHTML = this.alt;
  133. }
  134. }
  135.  
  136.  
  137. // Get the <span> element that closes the modal
  138. var span = document.getElementsByClassName("close")[0];
  139.  
  140. // When the user clicks on <span> (x), close the modal
  141. span.onclick = function() {
  142. modal.style.display = "none";
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement