手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

Javascript在网页中显示倒影时钟特效

时间:2024-11-19 02:36:13

1、为了方便举例,我就是用记事本来编辑演示。打开电脑中的记事本程序,首先输入基本的网页标签代码。

Javascript在网页中显示倒影时钟特效

2、然后在<head></head>标签之间定义style样式代码。.time{font-size: 45pt; line-height: 45pt; color: red;}

Javascript在网页中显示倒影时钟特效

3、然后,还在head标签之间定义函数,设定网页中显示的倒影区域的位置,如下。<script language=javascript>var jishi;function dy(){ if(document.all){ sj2.style.left=sj1.style.posleft; sj2.style.top=sj1.style.postopz+sj1.offsetheight-6; setsj(); }}

Javascript在网页中显示倒影时钟特效

4、定义函数设定时钟显示的内容和刷新频率,代码如下。fun罕铞泱殳ction setsj(){ var time=n髫潋啜缅ew date(); hours=time.gethours(); mins=time.getminutes(); secs=time.getseconds(); if(hours<10) hours="0"+hours; if(mins<10) mins="0"+mins; if(secs<10) secs="0"+secs; sj1.innerhtml=hours+":"+mins+":"secs sj2.innerhtml=hours+":"+mins+":"secs jishi=settimeout('setsj()',960);}

Javascript在网页中显示倒影时钟特效

5、接下来,在body标签中输入代码,让网页加载时显示时钟。<body onload="dy()"> <div class=time id=sj1 style="height:55px;left:110px;position:absolute;top:75px;width:10px"> </div>

Javascript在网页中显示倒影时钟特效

6、然后,输入倒影代码,这里使用IE滤镜flipv和alpha,代码如下。<div class=time id=sj2 style="FILTER: flipv() alpha(opacity=20); font-style:italic;position:absolute"></div>

Javascript在网页中显示倒影时钟特效

7、将记事本代码保存为.html网页格式后,打开预览效果。需要注意的是这种特效只可以在IE中显示。

Javascript在网页中显示倒影时钟特效
© 手抄报圈