| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1856 人关注过本帖, 1 人收藏
标题:HTML5动态时钟代码
只看楼主 加入收藏
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
结帖率:98.25%
收藏(1)
 问题点数:0 回复次数:7 
HTML5动态时钟代码
<!DOCTYPE html>

<html lang="en" xmlns="http://www.
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        #clock { stroke: black; stroke-linecap:square; fill: #fcfcfc; width: 500px; height: 500px; }
        #face { stroke-width: 2px; }
        #ticks { stroke-width: 1px; }
        #hour { stroke-width: 3px; stroke: #000; }
        #minute { stroke-width: 2px; stroke: #333; }
        #second { stroke-width: 1px; stroke: #f23; }
        #numbers { font-family: sans-serif; font-size: 8px; font-weight: bold; text-anchor: middle; stroke: none; fill: black; }
    </style>
</head>
<body>
    <svg id="clock" viewBox="0 0 100 100">
        <circle id="face" cx="50" cy="50" r="45" />
        <g id="ticks">
            <line x1="50.00" y1="5.000" x2="50.00" y2="10.00" />
            <line x1="72.50" y1="11.03" x2="70.00" y2="15.36" />
            <line x1="88.97" y1="27.50" x2="84.64" y2="30.00" />
            <line x1="95.00" y1="50.00" x2="90.00" y2="50.00" />
            <line x1="88.97" y1="72.50" x2="84.64" y2="70.00" />
            <line x1="72.50" y1="88.97" x2="70.00" y2="84.64" />
            <line x1="50.00" y1="95.00" x2="50.00" y2="90.00" />
            <line x1="27.50" y1="88.97" x2="30.00" y2="84.64" />
            <line x1="11.03" y1="72.50" x2="15.36" y2="70.00" />
            <line x1="5.000" y1="50.00" x2="10.00" y2="50.00" />
            <line x1="11.03" y1="27.50" x2="15.36" y2="30.00" />
            <line x1="27.50" y1="11.03" x2="30.00" y2="15.36" />
        </g>
        <g id="numbers">
            <text x="50" y="18">12</text>
            <text x="85" y="53">3</text>
            <text x="50" y="88">6</text>
            <text x="15" y="53">9</text>
        </g>
        <g id="hands">
            <line id="hour" x1="50" y1="50" x2="50" y2="24" />
            <line id="minute" x1="50" y1="50" x2="50" y2="20" />
            <line id="second" x1="50" y1="50" x2="50" y2="16" />
        </g>
    </svg>
    <script>
        setInterval(function () {
            var now = new Date(), min = now.getMinutes(), hour = now.getHours(), sec = now.getSeconds(),
                mangle = min * 6, hangle = (hour + min / 60) * 30, sangle = sec * 6,
                mhand = document.getElementById('minute'), hhand = document.getElementById('hour'), shand = document.getElementById('second');

            hhand.setAttribute('transform', 'rotate(' + hangle + ',50,50)');
            mhand.setAttribute('transform', 'rotate(' + mangle + ',50,50)');
            shand.setAttribute('transform', 'rotate(' + sangle + ',50,50)');
        }, 1000);
    </script>
</body>
</html>
搜索更多相关主题的帖子: HTML5 black second minute number 
2015-05-21 14:21
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
很好

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-05-21 14:45
wmf2014
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:216
帖 子:2039
专家分:11273
注 册:2014-12-6
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册


能编个毛线衣吗?
2015-05-21 16:22
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11771
专家分:43421
注 册:2006-5-13
收藏
得分:0 
试试看

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2015-05-21 17:16
龙牙
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大汉
等 级:贵宾
威 望:17
帖 子:769
专家分:6207
注 册:2013-3-18
收藏
得分:0 
学习了

只要心是晴朗的,人生就没有雨天。
2015-05-21 19:28
纳兰伽香
Rank: 10Rank: 10Rank: 10
来 自:北京
等 级:贵宾
威 望:10
帖 子:426
专家分:1650
注 册:2015-4-5
收藏
得分:0 

风回小院庭芜绿,柳眼春相续
2015-05-26 13:31
李阿呆、
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2015-5-26
收藏
得分:0 
好厉害哝
2015-06-15 11:26
星星对你眨眼
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-4-21
收藏
得分:0 
版主这么好心
2019-04-21 14:02
快速回复:HTML5动态时钟代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016738 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved