Advertisement
Chiropractorhouston

Mobile Responsive Form with Sticky Buttons

Apr 15th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Mobile Responsive Form</title>
  8. <style>
  9. body {
  10. font-family: Arial, sans-serif;
  11. }
  12.  
  13. .sticky-buttons {
  14. position: fixed;
  15. bottom: 20px;
  16. left: 20px;
  17. display: flex;
  18. flex-direction: column;
  19. align-items: flex-start;
  20. }
  21.  
  22. .call-now-button,
  23. .spot-booking-button,
  24. .refer-earn-button {
  25. display: inline-block;
  26. padding: 10px 20px;
  27. font-size: 16px;
  28. font-weight: bold;
  29. color: #fff;
  30. text-align: center;
  31. text-decoration: none;
  32. background-color: #ea2831;
  33. border: none;
  34. border-radius: 5px;
  35. cursor: pointer;
  36. margin-bottom: 10px;
  37. }
  38.  
  39. .call-now-button:hover,
  40. .spot-booking-button:hover,
  41. .refer-earn-button:hover {
  42. background-color: #c493a4;
  43. }
  44.  
  45. .form-overlay {
  46. display: none;
  47. position: fixed;
  48. top: 0;
  49. left: 0;
  50. width: 100%;
  51. height: 100%;
  52. background-color: rgba(0, 0, 0, 0.5);
  53. z-index: 9999;
  54. }
  55.  
  56. .form-popup {
  57. display: none;
  58. position: fixed;
  59. top: 50%;
  60. left: 50%;
  61. transform: translate(-50%, -50%);
  62. border: 1px solid #ccc;
  63. border-radius: 5px;
  64. z-index: 10000;
  65. max-width: 90%;
  66. background-color: #FFFFFF;
  67. }
  68.  
  69. .form-popup form {
  70. margin: 20px;
  71. }
  72.  
  73. .form-header {
  74. font-size: 24px;
  75. font-weight: bold;
  76. margin-top: 0;
  77. margin-bottom: 20px;
  78. }
  79.  
  80. input[type="text"],
  81. input[type="email"],
  82. input[type="tel"],
  83. textarea {
  84. display: block;
  85. width: 100%;
  86. padding: 10px;
  87. margin-bottom: 20px;
  88. border: 1px solid #ccc;
  89. border-radius: 5px;
  90. font-size: 16px;
  91. }
  92.  
  93. .form-popup form input[type="text"],
  94. .form-popup form input[type="email"],
  95. .form-popup form input[type="tel"],
  96. .form-popup form textarea {
  97. max-width: 80%;
  98. }
  99. input[type="submit"] {
  100. display: block;
  101. margin-top: 20px;
  102. padding: 10px 20px;
  103. font-size: 16px;
  104. font-weight: bold;
  105. color: #fff;
  106. text-align: center;
  107. text-decoration: none;
  108. background-color: #4CAF50;
  109. border: none;
  110. border-radius: 5px;
  111. cursor: pointer;
  112. }
  113.  
  114. input[type="submit"]:hover {
  115. background-color: #3e8e41;
  116. }
  117.  
  118. .form-popup.show {
  119. display: block;
  120. }
  121.  
  122. .form-overlay.show {
  123. display: block;
  124. }
  125.  
  126. .close-btn {
  127. position: absolute;
  128. top: 5px;
  129. right: 10px;
  130. font-size: 20px;
  131. font-weight: bold;
  132. color: #999;
  133. cursor: pointer;
  134. }
  135.  
  136. .close-btn:hover {
  137. color: #666;
  138. }
  139.  
  140. @media (max-width: 767px) {
  141. .form-popup {
  142. max-width: 100%;
  143. }
  144.  
  145. input[type="text"],
  146. input[type="email"],
  147. input[type="tel"],
  148. textarea {
  149. font-size: 14px;
  150. }
  151.  
  152. input[type="submit"] {
  153. font-size: 14px;
  154. }
  155. }
  156. </style>
  157. </head>
  158. <body>
  159. <div class="sticky-buttons">
  160. <a href="tel:1234567890" class="call-now-button">Call now</a>
  161. <button class="spot-booking-button">Spot Booking Offer</button>
  162. <button class="refer-earn-button">Refer and Earn</button>
  163. </div>
  164.  
  165. <div class="form-overlay" onclick="closeForm()"></div>
  166.  
  167. <div class="form-popup" id="spot-booking-form">
  168. <span class="close-btn" onclick="closeForm()">&times;</span>
  169. <form id="spot-booking-form" action="send1.php" method="POST">
  170.  
  171. <h2 class="form-header">Spot Booking Offer</h2>
  172. <input type="text" name="name" placeholder="Name" required>
  173. <input type="tel" name="phone" placeholder="Phone" required>
  174. <input type="email" name="email" placeholder="Email" required>
  175. <textarea name="message" placeholder="Message"></textarea>
  176. <input type="submit" value="Submit">
  177. </form>
  178. </div>
  179.  
  180. <div class="form-popup" id="refer-earn-form">
  181. <span class="close-btn" onclick="closeForm()">&times;</span>
  182. <form id="refer-earn-form" action="send1.php" method="POST">
  183.  
  184. <h2 class="form-header">Refer and Earn</h2>
  185. <input type="text" name="name" placeholder="Name" required>
  186. <input type="tel" name="phone" placeholder="Phone" required>
  187. <input type="email" name="email" placeholder="Email" required>
  188. <input type="text" name="friend_name" placeholder="Friend's Name" required>
  189. <input type="tel" name="friend_phone" placeholder="Friend's Phone" required>
  190. <input type="submit" value="Submit">
  191. </form>
  192. </div>
  193.  
  194. <script>
  195. document.querySelector(".spot-booking-button").addEventListener("click", function() {
  196. openForm("spot-booking-form");
  197. });
  198.  
  199. document.querySelector(".refer-earn-button").addEventListener("click", function() {
  200. openForm("refer-earn-form");
  201. });
  202.  
  203. function openForm(formId) {
  204. document.getElementById(formId).classList.add("show");
  205. document.querySelector(".form-overlay").classList.add("show");
  206. }
  207.  
  208. function closeForm() {
  209. document.querySelector(".form-overlay").classList.remove("show");
  210. document.querySelectorAll(".form-popup").forEach(function(form) {
  211. form.classList.remove("show");
  212. });
  213. }
  214. </script>
  215. </body>
  216. </html>
  217.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement