Advertisement
Guest User

Untitled

a guest
Feb 19th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. html = '''
  2. <!DOCTYPE html>
  3. <head>
  4.  
  5. <!-- ALL CREDIT GOES TO https://codepen.io/AllThingsSmitty/pen/JJavZN
  6. You didn't expect me to code this myself did you? -->
  7. <meta charset="UTF-8">
  8. <link rel="preconnect" href="https://fonts.googleapis.com">
  9. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  10. <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
  11. <title>Birthday Counter</title>
  12. <style>
  13. /* general styling */
  14. :root {
  15. --smaller: .75;
  16. }
  17.  
  18. * {
  19. box-sizing: border-box;
  20. margin: 0;
  21. padding: 0;
  22. }
  23.  
  24. html, body {
  25. height: 100%;
  26. margin: 0;
  27. }
  28.  
  29. body {
  30. align-items: center;
  31. background-color: {2};
  32. display: flex;
  33. font-family: -apple-system,
  34. BlinkMacSystemFont,
  35. "Segoe UI",
  36. Roboto,
  37. Oxygen-Sans,
  38. Ubuntu,
  39. Cantarell,
  40. "Helvetica Neue",
  41. sans-serif;
  42. }
  43.  
  44. .container {
  45. color: #333;
  46. margin: 0 auto;
  47. text-align: center;
  48. }
  49.  
  50. h1 {
  51. font-weight: normal;
  52. letter-spacing: .125rem;
  53. text-transform: uppercase;
  54. }
  55.  
  56. li {
  57. display: inline-block;
  58. font-size: 1.5em;
  59. list-style-type: none;
  60. padding: 1em;
  61. text-transform: uppercase;
  62. }
  63.  
  64. li span {
  65. display: block;
  66. font-size: 4.5rem;
  67. }
  68.  
  69. .emoji {
  70. display: none;
  71. padding: 1rem;
  72. }
  73.  
  74. .emoji span {
  75. font-size: 4rem;
  76. padding: 0 .5rem;
  77. }
  78.  
  79. @media all and (max-width: 768px) {
  80. h1 {
  81. font-size: calc(1.5rem * var(--smaller));
  82. }
  83.  
  84. li {
  85. font-size: calc(1.125rem * var(--smaller));
  86. }
  87.  
  88. li span {
  89. font-size: calc(3.375rem * var(--smaller));
  90. }
  91. }
  92. </style>
  93. </head>
  94.  
  95. <body>
  96. <div class="container">
  97. <h1 id="headline">Countdown to my birthday</h1>
  98. <div id="countdown">
  99. <ul>
  100. <li><span id="days"></span>days</li>
  101. <li><span id="hours"></span>Hours</li>
  102. <li><span id="minutes"></span>Minutes</li>
  103. <li><span id="seconds"></span>Seconds</li>
  104. </ul>
  105. </div>
  106. <div id="content" class="emoji">
  107. <span>🥳</span>
  108. <span>🎉</span>
  109. <span>🎂</span>
  110. </div>
  111. </div>
  112. <script type="text/javascript">
  113. (function () {
  114. const second = 1000,
  115. minute = second * 60,
  116. hour = minute * 60,
  117. day = hour * 24;
  118.  
  119. //I'm adding this section so I don't have to keep updating this pen every year :-)
  120. //remove this if you don't need it
  121. let today = new Date(),
  122. dd = String(today.getDate()).padStart(2, "0"),
  123. mm = String(today.getMonth() + 1).padStart(2, "0"),
  124. yyyy = today.getFullYear(),
  125. nextYear = yyyy + 1,
  126. dayMonth = "{1}/{0}/",
  127. birthday = dayMonth + yyyy;
  128.  
  129. today = mm + "/" + dd + "/" + yyyy;
  130. if (today > birthday) {
  131. birthday = dayMonth + nextYear;
  132. }
  133. //end
  134.  
  135. const countDown = new Date(birthday).getTime(),
  136. x = setInterval(function () {
  137. const now = new Date().getTime(),
  138. distance = countDown - now;
  139.  
  140. (document.getElementById("days").innerText = Math.floor(distance / day)),
  141. (document.getElementById("hours").innerText = Math.floor(
  142. (distance % day) / hour
  143. )),
  144. (document.getElementById("minutes").innerText = Math.floor(
  145. (distance % hour) / minute
  146. )),
  147. (document.getElementById("seconds").innerText = Math.floor(
  148. (distance % minute) / second
  149. ));
  150.  
  151. //do something later when date is reached
  152. if (distance < 0) {
  153. document.getElementById("headline").innerText = "It's my birthday!";
  154. document.getElementById("countdown").style.display = "none";
  155. document.getElementById("content").style.display = "block";
  156. clearInterval(x);
  157. }
  158. //seconds
  159. }, 0);
  160. })();
  161.  
  162. </script>
  163. </body>
  164. </html>
  165. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement