Add files via upload

This commit is contained in:
Sam 2023-05-06 18:52:10 +03:00 committed by GitHub
parent 65f5bf0c7e
commit 47ca543836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<!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>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="counter" data-target="20000"></div>
<span>Followers Counter</span>
<div class="counter" data-target="5000"></div>
<span>Subscribers Counter</span>
<script src="main.js"></script>
</body>
</html>

View File

@ -0,0 +1,23 @@
const counters = document.querySelectorAll('.counter');
// this could work for multiple counters
counters.forEach(counter => {
// start with 0 by default
counter.innerText = '0';
const updateCounter = () => {
const target = +counter.getAttribute('data-target');
const c = +counter.innerText;
// get the 0.1% to speed up things
const increment = target / 2000;
if(c < target) {
counter.innerText = `${Math.ceil(c + increment)}`;
setTimeout(updateCounter, 1)
} else {
counter.innerText = target;
}
};
updateCounter();
});

View File

@ -0,0 +1,20 @@
* {
box-sizing: border-box;
}
body {
background-color: #8FBC8F;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100vh;
margin: 0;
}
.counter {
font-size: 60px;
margin-top: 30px;
}
span{
font-size: 24px;
}