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

Random Captcha Generator

 How to generate random captcha || JAVASCRIPT techinc Here, you will going to teach how to generate random captcha by javascript #CODE: <!DOCTYPE html>     <html>         <head>             <title></title>         </head>         <body>             <canvas width=150 height=70 style="border:1px solid black;"></canvas><br>             <button style="width:150px;             height:40px;             color: red;             -webkit-tap-highlight-color:rgba(0,0,0,0);" onclick="generateCaptcha()">Generate Captcha</button>             <style type="text/css">                 body{     ...

The World Map

The World Map Here is the code of Designing the WORLD MAP by using Html-Css-Js only.Google Map provide you the option that is Map for Developer. So, CodoBlog provide you the code for how to design the map. CODE -     <!DOCTYPE html> <html> <head> <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <link href='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.css' rel='stylesheet'/>     <link rel="stylesheet" type="text/css" href=""> <title>The World Map</title> <style> *{ margin: 0; padding: 0; } #map{ width: 100vw; height: 100vh; } </style> </head> <body> <div id='map'></div> </body> <script src='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.js'></script> <script> mapboxgl.accessTok...

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;     ...