H5 Clock
2016-12-11 11:56
190 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>COLOCK</title>
<style>
html {
height:100%;
}
body {
height:100%;
background-color:white;
}
#yuan {
height:600px;
width:600px;
background-color:gray;
border:solid 2px black;
/*截取 弧度 矩形的四个定点 的 弧度转化*/
border-radius:300px;
position:relative;
margin:100px auto;
}
#fang{
height:200px;
width:560px;
/*相对位置的 定位 背景色*/
background-color:white;
border: solid 1px black;
position:absolute;
top:200px;
left:21px;
}
#date{
height:20px;
width:100px;
/*相对位置 定位背景色*/
/*background-color: blue;*/
/*字体的大小*/
font-size:15px;
font-weight: bold;
text-align: center;
position:absolute;
top:10px;
right:20px;
}
#time{
height:160px;
width:560px;
/*相对位置 定位背景色*/
/*background-color: blue;*/
/*字体的大小*/
font-size:120px;
text-align:center;
line-height: 160px;
position:absolute;
top:30px;
}
</style>
</head>
<body>
<!--时钟外围圆形-->
<div id="yuan">
<!--时钟圆的内部的方形显示框-->
<div id="fang">
<!--方形框 的显示的内容-->
<div id="date">1970-01-01</div>
<div id="time">01:01:01</div>
</div>
</div>
<script language="javaScript" type="text/javaScript">
// 创建函数
function showTime()
{
// 创建对象
var myDate=new Date();
// 获取当前的 日期: 年year 月month(计算机从 0 计算 月份表示为 0-11) 日day
var year=myDate.getFullYear();
var month=myDate.getMonth()+1;
var day=myDate.getDate();
// 获取当前的时间 : 时 hours 分 minute 秒 second
var hours=myDate.getHours();
var minute=myDate.getMinutes();
var second=myDate.getSeconds();
// 补齐显示格式
hours=hours<10?"0"+hours:hours;
minute=minute<10?"0"+minute:minute;
second=second<10?"0"+second:second;
// 获取 元素的索引 ID
var dateDiv=document.getElementById("date");
var timeDiv=document.getElementById("time");
// 改变文本的 值
// innerHTML
dateDiv.innerHTML=year+"-"+month+"-"+day;
timeDiv.innerHTML=hours+":"+minute+":"+second;
}
// 调用方法函数
showTime();
// 循环使用 方法
// setInterval 运行的方法 间隔时间(单位毫秒)
setInterval(showTime,1000);
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>COLOCK</title>
<style>
html {
height:100%;
}
body {
height:100%;
background-color:white;
}
#yuan {
height:600px;
width:600px;
background-color:gray;
border:solid 2px black;
/*截取 弧度 矩形的四个定点 的 弧度转化*/
border-radius:300px;
position:relative;
margin:100px auto;
}
#fang{
height:200px;
width:560px;
/*相对位置的 定位 背景色*/
background-color:white;
border: solid 1px black;
position:absolute;
top:200px;
left:21px;
}
#date{
height:20px;
width:100px;
/*相对位置 定位背景色*/
/*background-color: blue;*/
/*字体的大小*/
font-size:15px;
font-weight: bold;
text-align: center;
position:absolute;
top:10px;
right:20px;
}
#time{
height:160px;
width:560px;
/*相对位置 定位背景色*/
/*background-color: blue;*/
/*字体的大小*/
font-size:120px;
text-align:center;
line-height: 160px;
position:absolute;
top:30px;
}
</style>
</head>
<body>
<!--时钟外围圆形-->
<div id="yuan">
<!--时钟圆的内部的方形显示框-->
<div id="fang">
<!--方形框 的显示的内容-->
<div id="date">1970-01-01</div>
<div id="time">01:01:01</div>
</div>
</div>
<script language="javaScript" type="text/javaScript">
// 创建函数
function showTime()
{
// 创建对象
var myDate=new Date();
// 获取当前的 日期: 年year 月month(计算机从 0 计算 月份表示为 0-11) 日day
var year=myDate.getFullYear();
var month=myDate.getMonth()+1;
var day=myDate.getDate();
// 获取当前的时间 : 时 hours 分 minute 秒 second
var hours=myDate.getHours();
var minute=myDate.getMinutes();
var second=myDate.getSeconds();
// 补齐显示格式
hours=hours<10?"0"+hours:hours;
minute=minute<10?"0"+minute:minute;
second=second<10?"0"+second:second;
// 获取 元素的索引 ID
var dateDiv=document.getElementById("date");
var timeDiv=document.getElementById("time");
// 改变文本的 值
// innerHTML
dateDiv.innerHTML=year+"-"+month+"-"+day;
timeDiv.innerHTML=hours+":"+minute+":"+second;
}
// 调用方法函数
showTime();
// 循环使用 方法
// setInterval 运行的方法 间隔时间(单位毫秒)
setInterval(showTime,1000);
</script>
</body>
</html>
相关文章推荐
- H5-Canvas-Clock-时钟
- turn back the clock 时光倒转
- 第十二天H5进阶
- 戏说BIOS之Clock Generator
- h5 7
- The difference between CLOCK_MONOTONIC and CLOCK_REALTIME
- h5 17
- x86中断完全版----时钟服务(Clock Service -- INT 1AH)
- 第十八天H5进阶
- clock
- H5 Web Notification桌面推送消息
- [转]c++中计算运行时间 clock(),clock_t程序
- 原生页面和H5页面
- gettimeofday和clock_gettime的不同
- h5 canvas 仿知乎动态粒子背景
- 关于clock()计算进程运行的时间以及time()
- 安卓程序加载h5页面
- Linux下使用clock_gettime给程序计时
- Ahdroid 混合开发 接入H5界面以及webView控件详解
- 浅析linux设备驱动的clock(时钟)的注册