Skip to main content

Animated Modal Login Form

Screenshot
Body

In this tutorial we will show you how to create a Animated Modal Login Form for your system. This simple system shows you the popping up of login form by triggering or clicking the login button. And this is compose of PHP, Bootsrap and Javascript, this programs are written in a way that any one can understand and customize for their projects.

Sample Code

Index.php - This script of code is for the general output of the system for creating a modal form.

  1. <!DOCTYPE html><br />
  2. <html><br />
  3. <title>Animated Modal Login Form</title><br />
  4. <link rel="stylesheet" href="css/style.css"><br />
  5. <body><br />
  6. <ul><br />
  7. <li class="namelog"><a href="https://wwww.sourcecodester.com">Sourcecodester</a></li><br />
  8. <li><a style="margin-left: 15px;">Animated Modal Login Form</a></li><br />
  9. <li><a href="#login" onclick="document.getElementById('id01').style.display='block'" style="width:auto; margin-left:25px" class="login">Login</a></li><br />
  10. </ul><br />
  11. <div id="id01" class="modal"><br />
  12. <form class="modal-content animate" action="action_page.php"><br />
  13. <div class="imgcontainer"><br />
  14. <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span><br />
  15. <img src="images/logo.png" alt="Avatar" class="avatar"><br />
  16. </div><br />
  17. <div class="container"><br />
  18. <label><b>Username</b></label><br />
  19. <input type="text" placeholder="Enter Username" name="uname" required><br />
  20. <label><b>Password</b></label><br />
  21. <input type="password" placeholder="Enter Password" name="psw" required><br />
  22. <button type="submit">Login</button><br />
  23. <input type="checkbox"> Remember me<br />
  24. <span class="sign" style="margin-left: 70px;"><a href="signup.php"> Sign Up</a></span><br />
  25. </div><br />
  26. <div class="container" style="background-color:#f1f1f1"><br />
  27. <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button><br />
  28. <span class="psw">Forgot <a href="#">Password?</a></span><br />
  29. </div><br />
  30. </form><br />
  31. </div><br />
  32. <script><br />
  33. var modal = document.getElementById('id01');<br />
  34. window.onclick = function(event) {<br />
  35. if (event.target == modal) {<br />
  36. modal.style.display = "none";<br />
  37. }<br />
  38. }<br />
  39. </script><br />
  40. </body><br />
  41. </html>

Style.css - And for the style and design of the modal to make it more responsive.

  1. input[type=text], input[type=password] {<br />
  2. width: 100%;<br />
  3. padding: 12px 20px;<br />
  4. margin: 8px 0;<br />
  5. display: inline-block;<br />
  6. border: 1px solid #ccc;<br />
  7. box-sizing: border-box;<br />
  8. }<br />
  9. button {<br />
  10. background-color: #5388bf;<br />
  11. color: white;<br />
  12. padding: 14px 20px;<br />
  13. margin: 8px 0;<br />
  14. border: none;<br />
  15. cursor: pointer;<br />
  16. width: 100%;<br />
  17. }<br />
  18. .cancelbtn {<br />
  19. width: auto;<br />
  20. padding: 10px 18px;<br />
  21. background-color: #ca0e00;<br />
  22. }<br />
  23. .imgcontainer {<br />
  24. text-align: center;<br />
  25. margin: 24px 0 12px 0;<br />
  26. position: relative;<br />
  27. }<br />
  28. img.avatar {<br />
  29. width: 100%;<br />
  30. border-radius: 50%;<br />
  31. }<br />
  32. .container {<br />
  33. padding: 16px;<br />
  34. }<br />
  35. span.psw {<br />
  36. float: right;<br />
  37. padding-top: 16px;<br />
  38. }<br />
  39. .modal {<br />
  40. display: none;<br />
  41. position: fixed;<br />
  42. z-index: 1;<br />
  43. left: 0;<br />
  44. top: 0;<br />
  45. width: 100%;<br />
  46. height: 100%;<br />
  47. overflow: auto;<br />
  48. background-color: rgb(0,0,0);<br />
  49. background-color: rgba(0,0,0,0.4);<br />
  50. padding-top: 60px;<br />
  51. }<br />
  52. .modal-content {<br />
  53. background-color: #fefefe;<br />
  54. margin: 5% auto 15% auto;<br />
  55. border: 1px solid #888;<br />
  56. border-radius: 5px;<br />
  57. width: 35%;<br />
  58. }<br />
  59. .close {<br />
  60. position: absolute;<br />
  61. right: 25px;<br />
  62. top: 0;<br />
  63. color: #000;<br />
  64. font-size: 35px;<br />
  65. font-weight: bold;<br />
  66. }<br />
  67. .close:hover,<br />
  68. .close:focus {<br />
  69. color: red;<br />
  70. cursor: pointer;<br />
  71. }<br />
  72. .animate {<br />
  73. -webkit-animation: animatezoom 0.6s;<br />
  74. animation: animatezoom 0.6s<br />
  75. }<br />
  76. @-webkit-keyframes animatezoom {<br />
  77. from {-webkit-transform: scale(0)}<br />
  78. to {-webkit-transform: scale(1)}<br />
  79. }<br />
  80. @keyframes animatezoom {<br />
  81. from {transform: scale(0)}<br />
  82. to {transform: scale(1)}<br />
  83. }<br />
  84. @media screen and (max-width: 300px) {<br />
  85. span.psw {<br />
  86. display: block;<br />
  87. float: none;<br />
  88. }<br />
  89. span.sign {<br />
  90. display: block;<br />
  91. float: none;<br />
  92. }<br />
  93. .cancelbtn {<br />
  94. width: 100%;<br />
  95. }<br />
  96. }<br />
  97. body {margin:0;}</p>
  98. <p>ul {<br />
  99. list-style-type: none;<br />
  100. margin: 0;<br />
  101. padding: 0;<br />
  102. overflow: hidden;<br />
  103. background-color: #5388bf;<br />
  104. position: fixed;<br />
  105. top: 0;<br />
  106. width: 100%;<br />
  107. }</p>
  108. <p>li {<br />
  109. float: left;<br />
  110. }</p>
  111. <p>li a {<br />
  112. display: block;<br />
  113. color: white;<br />
  114. padding: 16px;<br />
  115. text-decoration: none;<br />
  116. margin-left: 385px;<br />
  117. }<br />
  118. .login {<br />
  119. display: block;<br />
  120. color: white;<br />
  121. text-decoration: none;<br />
  122. float:right;<br />
  123. background-color:green;<br />
  124. }<br />
  125. .namelog {<br />
  126. background-color:cadetblue;<br />
  127. }

Hope that you learn in this tutorial. And for more updates and programming tutorials don't hesitate to ask and we will answer your questions and suggestions. Don't forget to LIKE & SHARE this website.

Add new comment