HTML5超酷秒表动画 可暂停和重置秒表
关于HTML5和CSS3的时钟应用在之前我们已经分享过不少了,还有一些HTML5的日期选择应用。今天我们要分享一款基于HTML5和CSS3的圆盘秒表动画,秒表可以精确到0.001秒,并且可以在计时过程中暂停计时,同时秒表可以随时重置。

下面来分析一下实现的源代码,主要由HTML和CSS代码组成,CSS相对比较复杂,因为涉及到动画。
HTML代码:
<input id="help" name="controls" type="checkbox" />
<input id="settings" name="controls" type="checkbox" /> <input id="orange" name="color" type="radio" />
<input id="green" name="color" type="radio" checked="checked" /> <div> <input id="start" name="controls" type="radio" />
<input id="stop" name="controls" type="radio" />
<input id="reset" name="controls" type="radio" /> <div>
<div>
<div>
</div>
</div> <div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
:
</div> <div>
<div>
0 1 2 3 4 5
</div>
</div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
:
</div> <div>
<div>
0 1 2 3 4 5
</div>
</div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
:
</div> <div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div>
<div>
<div>
0 1 2 3 4 5 6 7 8 9
</div>
</div> </div> <div>
<label id="haptic" for="stop">
</label>
<label id="haptic2" for="start">
</label>
<label id="haptic3" for="reset">
</label> </div> </div> </div>
这里主要是定义了圆盘时钟的基本结构,以及开始、暂停和复位按钮。接下来重点是CSS代码:
CSS代码:
首先来定义一些动画:
@-webkit-keyframes start_haptic {from { -webkit-transform:scale(.98)}to {}}
@-webkit-keyframes stop_haptic {from { -webkit-transform:scale(.98)}to {}}
@-webkit-keyframes reset_haptic {from { -webkit-transform:scale(.98)}to {}}
@-webkit-keyframes launch {from { -webkit-transform:scale(1.2); opacity:} to {}}
@-webkit-keyframes info {from { -webkit-transform:scale(.8) translateY(100px); opacity:} to {}}
@-webkit-keyframes menu {from { -webkit-transform:scale(.9) translateY(-50px); opacity:} to {}}
@-webkit-keyframes reset {from {-webkit-transform:rotateZ(180deg);} 60%{ -webkit-transform:rotateZ(-30deg);} 70%{ -webkit-transform:rotateZ(10deg);} 80%{ -webkit-transform:rotateZ(-10deg);}to { -webkit-transform:rotateZ(0);}}
@-webkit-keyframes arrow { from { -webkit-transform: rotateZ(0deg);}to{-webkit-transform: rotateZ(360deg)}}
@-webkit-keyframes sec{ from { top:0px;}to{top:-300px;}}
@-webkit-keyframes sec1{ from { top:0px;}to{top:-180px;}}
再将这些动画在各个按钮被激活时启用这些动画:
.start:checked~.container .mil0{-webkit-animation-play-state:running;}
.stop:checked~.container .mil0{-webkit-animation-play-state:paused;}
.start:checked~.container .mil{-webkit-animation-play-state:running;}
.stop:checked~.container .mil{-webkit-animation-play-state:paused;}
.start:checked~.container .mil1{-webkit-animation-play-state:running;}
.stop:checked~.container .mil1{-webkit-animation-play-state:paused;}
.reset:checked~.container .mil1{-webkit-animation:none;top:;transition:.2s;}
.reset:checked~.container .mil0{-webkit-animation:none;top:;transition:.2s;}
.reset:checked~.container .mil{-webkit-animation:none;top:;transition:.2s;}
.start:checked~.container .sec{-webkit-animation-play-state:running;}
.stop:checked~.container .sec{-webkit-animation-play-state:paused;}
.reset:checked~.container .sec{-webkit-animation:none;top:;transition:.2s;}
.start:checked~.container .sec1{-webkit-animation-play-state:running;}
.stop:checked~.container .sec1{-webkit-animation-play-state:paused;}
.reset:checked~.container .sec1{-webkit-animation:none;top:;transition:.2s;}
.start:checked~.container .min{-webkit-animation-play-state:running;}
.stop:checked~.container .min{-webkit-animation-play-state:paused;}
.reset:checked~.container .min{-webkit-animation:none;top:;transition:.2s;}
.start:checked~.container .min1{-webkit-animation-play-state:running;}
.stop:checked~.container .min1{-webkit-animation-play-state:paused;}
.reset:checked~.container .min1{-webkit-animation:none;top:;transition:.2s;}
.start:checked~.container .arrow{-webkit-animation-play-state:running;}
.stop:checked~.container .arrow{-webkit-animation-play-state:paused;}
.reset:checked~.container .arrow{-webkit-animation:reset .4s; -webkit-animation-fill-mode:forwards;}
.controls{ height:60px;width:200px;margin:0 auto; position:relative; }
.stop_,.start_{position:absolute; z-index:; height:60px; width:80px; left:60px; transition:.2s; background-position:center center;background-repeat:no-repeat;}
最后将源代码一并附上,下载地址>>
HTML5超酷秒表动画 可暂停和重置秒表的更多相关文章
- 16款最佳HTML5超酷动画演示及源码
1.HTML5/CSS3图片选择动画 可选择多张图片 之前我们已经分享过几款很酷的HTML5图片特效,像HTML5 3D图片折叠特效.HTML5 3D旋转图片相册等应用.今天我们来分享一款既炫酷又实用 ...
- HTML5/CSS3超酷环形动画菜单
在线演示 本地下载
- 超酷JQuery动画分页按钮,鼠标悬停滑动展开
1.效果及功能说明 animate动画分页按钮制作鼠标悬停分页按钮上滑动展开分页按钮,鼠标离开后分页按钮收缩 2.实现原理 主要是靠动画方法,来让原本的箭头图像的长度发生变长,正好可以融入下标题的文字 ...
- 超酷创意HTML5动画演示及代码
HTML5是未来的网页开发神器,今天分享的这些HTML5动画大部分利用了CSS3的动画属性来实现,废话不多说,直接上演示和代码. HTML5/CSS3实现大风车旋转动画 这次我们要来分享一款很酷的HT ...
- 推荐9款使用CSS3实现的超酷动画效果
大家都知道,在网页制作时使用CSS技术,可以有效地对页面的布局.字体.颜色.背景和其它效果实现更加精确的控制.只要对相应的代码做一些简单的修改,就可以改变同一页面的不同部分,或者页数不同的网页的外观和 ...
- 10款基于HTML5+CSS3实现的超酷源码动画
1.基于Bootstrap的jQuery登录表单 这是一款基于Bootstrap的登录表单,表单的外观自然不用说,沿用了Bootstrap的风格,非常漂亮.这款登录表单有一个经过CSS3处理过的头像图 ...
- 8款超酷的HTML5 3D图片动画源码
1.HTML5移动端图片左右切换动画 今天要给大家分享一款很不错的图片左右切换焦点图动画,并且支持移动端触摸滑动.功能上,这款HTML5图片播放器支持鼠标滑动.手机端触摸滑动以及自动播放.外观上,这款 ...
- 7款超酷HTML5 3D动画精选应用及源码
对以前来讲,3D动画拿到网页上展示是一件非常奢侈的事情,第一是浏览器不够先进,第二是大部分只能用flash实现伪3D.HTML5的出现,让实现网页3D动画变得非常简单,当然前提是你不要再使用像IE67 ...
- 超酷震撼 HTML5/CSS3动画应用及源码
HTML5可以制作非常华丽的动画效果,这点通过之前的分享学习我们已经有深刻的了解了,今天我们主要来分享一些HTML5结合CSS3形成的超炫震撼的动画应用以及它们的源代码,真的非常不错. 1.纯CSS3 ...
随机推荐
- BZOJ.3620.似乎在梦中见过的样子(KMP)
题目链接 /* 896kb 6816ms A+B+A是KMP的形式,于是固定左端点,对于每个位置i,若fail[i]所能到的点k中(k=fail[fail[fail[...]]]),有满足len(l~ ...
- BZOJ.4293.[PA2015]Siano(线段树)
题目链接 \(Description\) 有一片n亩的土地,要在这上面种草. 在每一亩土地上都种植了一种独一无二的草,其中,第\(i\)亩土地的草每天会长高\(a[i]\)厘米. 一共会进行\(m\) ...
- javaweb中为mysql的curd多个值的语句
更新语句 String sql = "update student set num=?,name=?,birthday=?,score=?,password=? where id=?&quo ...
- failed to initialize unity graphics 错误解决方法(win7 unity4.x)
重装系统后 unity 4.7.2安装之后,破解完毕就有了个Fatal error; 提示信息为:failed to initialize unity graphics 解决办法:依旧是先查看了网上 ...
- 工具类TestTools
一些方法可能要使用到该工具类,该工具类中的方法包括从链接数据库到数据表中记录的增删改查. package JDBCTest; import java.io.InputStream; import ja ...
- Unity3D游戏制作(三)——移动平台上的角色阴影制作
本系列文章由 Amazonzx 编写,欢迎转载,转载请注明出处. http://blog.csdn.net/amazonzx/article/details/7973740 本文将重点介绍两种目前在移 ...
- Art: Neural Style Transfer
Andrew Ng deeplearning courese-4:Convolutional Neural Network Convolutional Neural Networks: Step by ...
- 【Spark】Spark-架构
Spark-架构 Spark Master at spark://node-01:7077 spark clustermanager_百度搜索 看了之后不再迷糊-Spark多种运行模式 - 简书 Sp ...
- sprintf将CString转换成char[]
在MFC中使用sprintf()函数将CString转换成char[]时,char[]只接受第一个字符 使用的是VS2008 CString name;dbName="test" ...
- c++设计一个无法被继承的类
要求是该类不能被继承,但是能够像正常的类一样使用.那么一下方法就不符合题目要求: 1.构造函数和析构函数设置为private.这样就不能定义一个类的实例 2.类似于singleton模式那样,定义一个 ...