forked from iamrahulmahato/master-web-development
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request iamrahulmahato#955 from amanver45/new-year
New year countdown
- Loading branch information
Showing
7 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>New Year Countdown</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<h2>Countdown to New Year</h2> | ||
<div class="year">2025</div> | ||
<div class="countdown"> | ||
<div id="day">00</div> | ||
<div id="hour">00</div> | ||
<div id="minute">00</div> | ||
<div id="second">00</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const dayEl = document.getElementById("day"); | ||
const hourEl = document.getElementById("hour"); | ||
const minuteEl = document.getElementById("minute"); | ||
const secondEl = document.getElementById("second"); | ||
|
||
const newYearTime = new Date("Jan 1, 2025 00:00:00").getTime(); | ||
|
||
updateCountdown(); | ||
|
||
function updateCountdown() { | ||
const now = new Date().getTime(); | ||
const gap = newYearTime - now; | ||
|
||
const second = 1000; | ||
const minute = second * 60; | ||
const hour = minute * 60; | ||
const day = hour * 24; | ||
|
||
const d = Math.floor(gap / day); | ||
const h = Math.floor((gap % day) / hour); | ||
const m = Math.floor((gap % hour) / minute); | ||
const s = Math.floor((gap % minute) / second); | ||
dayEl.innerText = d; | ||
hourEl.innerText = h; | ||
minuteEl.innerText = m; | ||
secondEl.innerText = s; | ||
setTimeout(updateCountdown, 1000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
body | ||
{background-image: url(b.jpg); | ||
} | ||
body { | ||
margin: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
height: 100vh; | ||
justify-content: center; | ||
font-family: cursive; | ||
background-color: slateblue; | ||
overflow: hidden; | ||
} | ||
|
||
h2 { | ||
color: yellow; | ||
text-align: center; | ||
text-transform: uppercase; | ||
letter-spacing: 4px; | ||
font-size: xx-large; | ||
} | ||
|
||
.year { | ||
font-size: 5em; | ||
color: orange; | ||
font-weight: bold; | ||
} | ||
|
||
.countdown { | ||
margin: 30px; | ||
background-color: rgba(0, 0, 0, 0.1); | ||
width: 100%; | ||
color: black; | ||
height: 120px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.countdown div { | ||
margin: 0 15px; | ||
font-size: 2.5em; | ||
font-weight: 500; | ||
margin-top: -25px; | ||
position: relative; | ||
text-align: center; | ||
width: 100px; | ||
} | ||
|
||
.countdown div::before { | ||
content: ""; | ||
position: absolute; | ||
bottom: -30px; | ||
left: 0; | ||
font-size: 0.35em; | ||
line-height: 35px; | ||
text-transform: uppercase; | ||
letter-spacing: 1px; | ||
font-weight: 500; | ||
width: 100%; | ||
height: 35px; | ||
} | ||
|
||
.countdown #day::before { | ||
content: "Days"; | ||
} | ||
.countdown #hour::before { | ||
content: "Hours"; | ||
} | ||
.countdown #minute::before { | ||
content: "Minutes"; | ||
} | ||
.countdown #second::before { | ||
content: "Seconds"; | ||
} |