-
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.
- Loading branch information
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
const counters = document.querySelectorAll(".counter"); | ||
|
||
counters.forEach((counter) => { | ||
counter.innerText = "0"; | ||
|
||
const upddateCounter = () => { | ||
const target = +counter.getAttribute("data-target"); | ||
const c = +counter.innerText; | ||
|
||
const increment = target / 200; | ||
|
||
if (c < target) { | ||
counter.innerText = `${Math.ceil(c + increment)}`; | ||
setTimeout(upddateCounter, 1); | ||
} else { | ||
counter.innerText = target; | ||
} | ||
}; | ||
|
||
upddateCounter(); | ||
}); |
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,38 @@ | ||
<!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" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" | ||
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer" | ||
/> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<title>Incrementing | Counter</title> | ||
</head> | ||
<body> | ||
<div class="counter-container"> | ||
<i class="fab fa-twitter fa-3x"></i> | ||
<div class="counter" data-target="12000"></div> | ||
<span>Twitter Followers</span> | ||
</div> | ||
|
||
<div class="counter-container"> | ||
<i class="fab fa-youtube fa-3x"></i> | ||
<div class="counter" data-target="5000"></div> | ||
<span>YouTube Subscribers</span> | ||
</div> | ||
|
||
<div class="counter-container"> | ||
<i class="fab fa-facebook fa-3x"></i> | ||
<div class="counter" data-target="7500"></div> | ||
<span>facebook Fans</span> | ||
</div> | ||
|
||
<script src="./app.js"></script> | ||
</body> | ||
</html> |
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,44 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap"); | ||
*::after, | ||
*::before { | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
background-color: #8e44ad; | ||
color: #fff; | ||
font-family: "Roboto Mono", sans-serif; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.counter-container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
text-align: center; | ||
margin: 30px 50px; | ||
} | ||
|
||
.counter { | ||
font-size: 60px; | ||
margin-top: 10px; | ||
} | ||
|
||
@media (max-width: 580px) { | ||
body { | ||
flex-direction: column; | ||
} | ||
.counter-container { | ||
margin: 20px 40px; | ||
} | ||
.counter { | ||
font-size: 40px; | ||
margin-top: 5px; | ||
} | ||
} |