JavaScript writes round digital clocks by object-oriented

Source: Internet
Author: User

Effect, the code is as follows

<! DOCTYPE html>. Hour{height:200px;width:200px;position:relative;top:100px;left:100px;border-radius:50%; BORDER:3PX Solid #666666;display:inline-block}. Minute{height:200px;width:200px;position:relative;top:100px;left:100px;border-radius:50%; BORDER:3PX Solid #666666;display:inline-block}. Second{height:200px;width:200px;position:relative;top:100px;left:100px;border-radius:50%; BORDER:3PX Solid #666666;display:inline-block}. Innerleft{height:178px;width:89px;position:absolute;top:1px;left:1px;border-radius:178px 0 0178px; Border-bottom:10px solid #009bff; border-top:10px solid #009bff; border-left:10px solid #009bff; background:white; transform-origin:100% 50%;} . Innerright{height:178px;width:89px;position:absolute;top:1px;right:1px;border-radius:0 178px 178px 0; border-bottom:10px solid #009bff, border-top:10px solid #009bff, border-right:10px solid #009bff; background:white; transform-origin:0 50%; Transform:rotate (-180deg);} . Cover{position:absolute;height:200px;width:100px;border-radius:198px 0 0 198px;background:white;z-index:1} input{position:absolute;top:60px;left:120px;} Span{height:20px;width:80px;line-Height:20px;display:block;position:absolute;;            top:90px; Z-index:2; left:60px;font-size:16px;font-weight:bold;text-Align:center}</style>window.onload=function(){            functionRoll (progress,n) {Innerleft= Document.queryselector ('. ') + This. ClassName + '. Innerleft '); Innerright= Document.queryselector ('. ') + This. ClassName + '. Innerright '); Span= Document.queryselector ('. ') + This. ClassName + ' span '); Cover= Document.queryselector ('. ') + This. ClassName + '. Cover '); Span.innerhtml= Progress+ ' + This. ClassName; if(Progress*n < 180) {Console.log ( This. ClassName); Cover.style.display= ' Block '; InnerLeft.style.transform= ' Rotate (' + (progress*n) + ' deg) '; InnerRight.style.transform= ' Rotate (' + (progress*n-180) + ' deg) '; }                Else{Console.log ( This. ClassName); Cover.style.display= ' None '; InnerLeft.style.transform= ' Rotate (' + (progress*n) + ' deg) '; InnerRight.style.transform= ' Rotate (0deg) '; }            }            varT=setinterval (function(){                varTime=NewDate (); varhours=time.gethours (); varminutes=time.getminutes (); varseconds=time.getseconds (); varHour=document.queryselector ('. Hour ')); varMinute=document.queryselector ('. Minute ')); varSecond=document.queryselector ('. Second ')); Roll.call (Hour,hours,30); Roll.call (Minute,minutes,6); Roll.call (Second,seconds,6); },1000); }    </script></body>

In the programming process to use tansform to achieve dynamic effects, but there will be a return to zero reverse, and finally no use, and then go to explore it.

JavaScript writes round digital clocks by object-oriented

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.