TANMOY1

Sale Countdown Timer

Oct 9th, 2025
4,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <style>
  7. @keyframes wave {
  8. 0% {
  9. background-position: 0 0;
  10. }
  11. 50% {
  12. background-position: 100% 0;
  13. }
  14. 100% {
  15. background-position: 0 0;
  16. }
  17. }
  18.  
  19. .countdown-bar {
  20. display: flex;
  21. justify-content: center;
  22. align-items: center;
  23. background: linear-gradient(to right, #000000, #4770DB);
  24. background-size: 200% 100%;
  25. animation: wave 10s ease infinite;
  26. padding: 5px; /* Reduced padding to make the block smaller */
  27. font-family: Arial, sans-serif;
  28. font-size: 14px;
  29. font-weight: bold;
  30. text-transform: uppercase;
  31. color: white;
  32. }
  33.  
  34. .countdown-container {
  35. display: flex;
  36. align-items: center;
  37. justify-content: center; /* Center text and timer horizontally */
  38. width: 100%;
  39. max-width: 900px;
  40. margin: 0 auto;
  41. gap: 5px; /* Reduced gap between text and timer */
  42. }
  43.  
  44. .countdown-text {
  45. color: white;
  46. margin-right: 5px; /* Reduced margin for smaller block */
  47. font-size: 13px; /* Reduced font size */
  48. }
  49.  
  50. .countdown {
  51. display: flex;
  52. align-items: center;
  53. gap: 2px; /* Reduced gap between time sections */
  54. }
  55.  
  56. .time-section {
  57. display: flex;
  58. align-items: center;
  59. justify-content: center;
  60. background-color: #ffffff;
  61. color: #000000;
  62. width: 30px; /* Reduced width for smaller block */
  63. height: 30px; /* Reduced height for smaller block */
  64. margin: 0;
  65. border-radius: 5px;
  66. font-weight: bold;
  67. font-size: 14px; /* Adjusted font size */
  68. }
  69.  
  70. .time-label {
  71. font-size: 8px; /* Reduced font size */
  72. margin-left: 2px;
  73. margin-right: 2px;
  74. }
  75.  
  76. /* Adjust layout for desktop screens */
  77. @media (min-width: 1024px) {
  78. .countdown-container {
  79. gap: 5px; /* Maintain smaller gap for desktop */
  80. }
  81.  
  82. .countdown-text {
  83. margin-right: 5px; /* Reduced margin on desktop */
  84. font-size: 12px; /* Ensure text size is consistent */
  85. }
  86. }
  87. </style>
  88. <title>Countdown Timer</title>
  89. </head>
  90. <body>
  91.  
  92. <div class="countdown-bar">
  93. <div class="countdown-container">
  94. <div class="countdown-text">🏷️ GET 40% OFF! + FREE SHIPPING✨ ENDS IN </div>
  95. <div id="countdown" class="countdown">
  96. <div class="time-section" id="hours">00</div><div class="time-label">HRS</div>
  97. <div class="time-section" id="minutes">00</div><div class="time-label">MIN</div>
  98. <div class="time-section" id="seconds">00</div><div class="time-label">SEC</div>
  99. </div>
  100. </div>
  101. </div>
  102.  
  103. <script>
  104. function startCountdown() {
  105. let countdownDuration = 29 * 60; // 29 minutes in seconds
  106. let countdownEnd = parseInt(localStorage.getItem('countdownEnd'));
  107.  
  108. // If there's no previous countdownEnd, set it to now + countdownDuration
  109. if (!countdownEnd || countdownEnd < Date.now()) {
  110. countdownEnd = Date.now() + countdownDuration * 1000;
  111. localStorage.setItem('countdownEnd', countdownEnd);
  112. }
  113.  
  114. const x = setInterval(function() {
  115. const now = Date.now();
  116. const distance = countdownEnd - now;
  117.  
  118. const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  119. const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  120. const seconds = Math.floor((distance % (1000 * 60)) / 1000);
  121.  
  122. document.getElementById("hours").innerHTML = (hours < 10 ? "0" : "") + hours;
  123. document.getElementById("minutes").innerHTML = (minutes < 10 ? "0" : "") + minutes;
  124. document.getElementById("seconds").innerHTML = (seconds < 10 ? "0" : "") + seconds;
  125.  
  126. if (distance < 0) {
  127. clearInterval(x);
  128. localStorage.setItem('countdownEnd', Date.now() + countdownDuration * 1000);
  129. startCountdown(); // Restart the countdown
  130. }
  131. }, 1000);
  132. }
  133.  
  134. startCountdown();
  135. </script>
  136.  
  137. </body>
  138. </html>
Advertisement
Add Comment
Please, Sign In to add comment