Skip to main content

How to create Stopwatch by using Html and Javascript | Digital Stopwatch

How to create Stopwatch by using Html-Css-Javascript || Digital StopWatch 



#CODE  : 


<!DOCTYPE html>
<html>
<head>
<title>Stopwatch</title>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
body{
margin: 0;
    padding: 0;
    background-color: #6495ED;
    box-sizing: border-box;

}
.con{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border-radius: 5px;
background: #ececec;
box-shadow: 20px 20px 60px red,
-20px -20px 60px #fff;
height: 380px;
width: 280px;
}
.time{
border-radius: 50%;
background: #fff;
box-shadow: inset 20px 20px 60px green,
inset -20px -20px 60px #fff;
height: 150px;
width: 150px;
position: absolute;
margin: 60px 0 0 65px;
transform: scale(1.5);
}
.buttons{
text-align: center;
bottom: 40px;
z-index: 99;
position: absolute;
display: flex;
left: 65px;
}
.buttons div{
margin-right: 50px;
}
.fa{
box-shadow: 5px 5px 10px blue, -5px -5px 10px #fff;
height: 30px;
width: 30px;
line-height: 30px;
border-radius: 50%;
padding: 10px;
text-align: center;
background: #ececec;
}
.fa:active{
box-shadow: inset 20px 20px 60px #d9d9d9, inset -20px -20px 60px #ececec;
}
.timebox{
display: flex;
text-align: center;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
position: absolute;
font-size: 30px;
color: #000000;
text-shadow: 3px 3px 5px yellow;
}
</style>
</head>
<body>
<div class="con">
<div class="time">
<div class="timebox">
<div class="hr">00 :</div>
<div class="min">00 :</div>
<div class="sec">00 :</div>
</div>
</div>
<div class="buttons">
<div class="change"><i class="fa fa-play"></i></div>
<div class="reset"><i class="fa fa-undo"></i></div>
</div>
</div>
<script type="text/javascript">
var pla = document.querySelector(".fa-play");
var reset = document.querySelector(".fa-undo");
var hr = document.querySelector(".hr");
var min = document.querySelector(".min");
var sec = document.querySelector(".sec");
pla.addEventListener('click',start);
reset.addEventListener('click',reseter);
var seconds = 0;
var minutes = 0;
var hour = 0;
var interval;
var status = 1;
var dishr, dismin , dissec
function increase(){
seconds++;
if (seconds / 100 ===1) {
minutes++
seconds = 0
if (minutes / 60 ===1) {
hour++
minutes = 0
}
}
dissec = seconds;
dismin = minutes;
dissec = seconds;
if(seconds < 10){
dissec = "0" + seconds;
}
if(minutes < 10){
dismin = "0" + minutes;
}
if(hour < 10){
dishr = "0" + hour;
}
sec.innerHTML  = dissec;
min.innerHTML = dismin + " "+":";
hr.innerHTML = dishr + " "+":";

}
function start(){
if (status==1) {
interval = setInterval(increase,10)
pla.className = "fa fa-stop";
status = 0;
}
else if(status==0){
clearInterval(interval);
status =1;
pla.className = "fa fa-play";
}
}
function reseter(){
seconds = 0;
minutes = 0;
hour = 0;
hr.innerHTML = "00 :" ;
min.innerHTML = "00 :" ;
sec.innerHTML = "00 :" ;

}
</script>
</body>
</html>

#OUTPUT : 







                                        

Comments

The Most Populer

How to Generate Barcode || code for Barcode

|| Random Barcode Generator || Barcode on the basis length of text || #CODE :                 Barcode.html ==>        <html>        <head>            <title>Barcode Generator</title>            <link rel="stylesheet" href="Barcode.css">     </head>     <body>         <div>Barcode Generator</div>         <input type="text" placeholder="Type..."/>         <button onclick="generate()">Generate Barcode</button>           <svg id="barcode"></svg>           <script src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.11.0/JsBarcode.all.min.js"></script>           <script>               JsBarcode("#barcode","#Hello",{                   background:"#161748",                   lineColor:"#ffffff"               });               function generate(){                   var val = docu

Design 3D Block with hover animation

        How To Design The 3D Block With Hover Effect. Here is the code of How to design the 3D block design by using only html and css.                          By using html-css you can make a lots of designs and animations. Few done by me                          and   somewhat expect from you . Try to watch all the videos by codoblog. And stay                                              connected.                 CODE -                         <html>           <head> <style type="text/css"> body{ background-color: black; } .wrap{ margin-top: 150px; perspective:1000px; perspective-origin:50% 50%; } .cube{ margin: auto; position: relative; height: 200px; width: 200px; transform-style:preserve-3d; } .cube > div{ position:absolute; box-sizing:border-box; padding: 10px; height: 100%; width: 100%; opacity: 0.7; background-color: #000; border: solid 1px #eeeeee; color: r

Code for icon design | camera icon code | html-css code

 Camera ICON creation || Code for the camera icon  Here is the code for camera icon design..try with your efforts..! ICON #CODE : >>                <!DOCTYPE html> <html> <head> <title>Camera Icon Creation</title> <style type="text/css"> body{ margin:0; background-color: lightblue; } .outer{     width: 50%;     height: 100vh;     display: flex;     justify-content: center;     align-items: center;     margin: 0 auto; } .body{     background-color: white;     border-radius: 30%;     width: 11rem;     height: 11rem;     position: relative;     box-shadow: 1px 1px 6px 1px slategrey; } .red{     border-radius: 50%;     background-color: crimson;     width: 10px;     height: 10px;     position: absolute;     top: 10%;     left: 10%;     margin: 4px; } .flash{     width: 20%;     height: 8px;     border-radius: 25% / 30%;     background-color: #ccc;     box-shadow: inset 1px 1px 6px 1px slategrey;     position: absolute;