Create a simple counter application project in javascript with using HTML & CSS..
HTML part:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="count-value">
<h1 id="result"></h1>
<div class="press">
<button onclick="increase()">+</button>
<button onclick="decrease()">-</button>
<button onclick="reset()">Reset</button>
</div>
</div>
</body>
</html>
JS part:
<script>
let count = 0;
let element = document.getElementById("result");
element.innerText = count;
function increase() {
count = count + 1;
element.innerText = count;
}
function decrease() {
count = count - 1;
element.innerText = count;
}
function reset() {
count = 0;
element.innerText = count;
}
</script>
CSS style:
<style>
body {
/* border: 2px solid green; */
background: url(https://img.freepik.com/free-vector/gradient-numerology-background_23-2150051043.jpg?ga=GA1.1.1592619047.1747411105&semt=ais_items_boosted&w=740)repeat;
width: 100%;
height: 100vh;
margin: auto;
display: flex;
justify-content: center;
align-items: center;
}
.count-value {
background-color: white;
/* border: 1px solid; */
box-shadow: rgba(50, 50, 93, 0.25) 0px 30px 60px -12px inset, rgba(0, 0, 0, 0.3) 0px 18px 36px -18px inset;
border-radius: 6px;
width: 300px;
height: 150px;
}
h1 {
/* border: 1px solid; */
padding-left: 140px;
}
.press {
/* border: 1px solid; */
border-radius: 6px;
width: 300px;
height: 30px;
gap: 10px;
padding: 5px 0px;
margin: auto;
display: flex;
justify-content: center;
}
</style>
Output: