Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. /* The Modal (background) */
  6. .modal4 {
  7. display: none;
  8. position: fixed;
  9. z-index: 1;
  10. padding-top: 100px;
  11. left: 0;
  12. top: 0;
  13. width: 100%;
  14. height: 100%;
  15. overflow: auto;
  16. background-color: rgb(0,0,0);
  17. background-color: rgba(0,0,0,0.4);
  18. }
  19.  
  20. /* Modal content1 */
  21. .modal4-content2 {
  22. position: relative;
  23. background-color: #fefefe;
  24. margin: auto;
  25. padding: 0;
  26. border: 1px solid #888;
  27. width: 80%;
  28. box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
  29. -webkit-animation-name: animatetop;
  30. -webkit-animation-duration: 0.4s;
  31. animation-name: animatetop;
  32. animation-duration: 0.4s
  33. }
  34.  
  35. /* Add Animation */
  36. @-webkit-keyframes animatetop {
  37. from {top:-300px; opacity:0}
  38. to {top:0; opacity:1}
  39. }
  40.  
  41. @keyframes animatetop {
  42. from {top:-300px; opacity:0}
  43. to {top:0; opacity:1}
  44. }
  45.  
  46. /* The Close Button */
  47. .close {
  48. color: white;
  49. float: right;
  50. font-size: 28px;
  51. font-weight: bold;
  52. }
  53.  
  54. .close:hover,
  55. .close:focus {
  56. color: #000;
  57. text-decoration: none;
  58. cursor: pointer;
  59. }
  60.  
  61. .modal4-header2 {
  62. padding: 2px 16px;
  63. background-color: #5cb85c;
  64. color: white;
  65. }
  66.  
  67. .modal4-body {padding: 2px 16px;}
  68.  
  69. .modal4-footer2 {
  70. padding: 2px 16px;
  71. background-color: #5cb85c;
  72. color: white;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77.  
  78. <h2>Animated Modal with header1 and footer1</h2>
  79.  
  80. <!-- Trigger/Open The Modal -->
  81. <button id="myBtn4">Open Modal</button>
  82.  
  83. <!-- The Modal -->
  84. <div id="myModal4" class="modal4">
  85.  
  86. <!-- Modal content1 -->
  87. <div class="modal4-content2">
  88. <div class="modal4-header2">
  89. <span class="close">&times;</span>
  90. <h2>Modal header1</h2>
  91. </div>
  92. <div class="modal4-body">
  93. <p>Some text in the Modal Body</p>
  94. <p>Some other text...</p>
  95. </div>
  96. <div class="modal4-footer2">
  97. <h3>Modal footer1</h3>
  98. </div>
  99. </div>
  100.  
  101. </div>
  102.  
  103. <script>
  104. // Get the modal
  105. var modal4 = document.getElementById('myModal4');
  106.  
  107. // Get the button that opens the modal
  108. var btn = document.getElementById("myBtn4");
  109.  
  110. // Get the <span> element that closes the modal
  111. var span = document.getElementsByClassName("close")[0];
  112.  
  113. // When the user clicks the button, open the modal
  114. btn.onclick = function() {
  115. modal4.style.display = "block";
  116. }
  117.  
  118. // When the user clicks on <span> (x), close the modal
  119. span.onclick = function() {
  120. modal4.style.display = "none";
  121. }
  122.  
  123. // When the user clicks anywhere outside of the modal, close it
  124. window.onclick = function(event) {
  125. if (event.target == modal4) {
  126. modal4.style.display = "none";
  127. }
  128. }
  129. </script>
  130.  
  131. </body>
  132. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement