CSS3实现的闪烁跳跃进度条示例(附源码)

所属分类: 网页制作 / CSS 阅读数: 427
收藏 0 赞 0 分享
这个示例的原理是通过大量的css3属性来实现的,如:animation、transform、keyframes等等属性。值得注意的是这个示例采用了结构性伪类选择符E:nth-child(n),来进行对HTML元素的选择以及控制输出。相信这个伪类选择符在将来会是一个很强大的一个工具。推荐大家多多了解以及实践使用。这个伪类选择符E:nth-child(n)的含义是匹配父元素的第n个子元素E。 例如:ul li:nth-child(3)表示的是选择<ul>元素里面的第3个<li>。提示一下,该属性在IE8(包含IE8)版本以下是不支持的。

建议开发童鞋使用跨平台开发工具——统一开发环境UDE来进行查看、调试、开发哦~~它是一款HTML5跨平台一站式应用开发、调试和部署工具, 支持HTML5跨平台开发,原Java跨平台插件支持Android/Symbian/Kjava的跨平台和原生开发,为开发者提供丰富的应用模板、示例代码及开发者社区服务,已覆盖Android、iOS、WP、Symbian、Kjava操作系统平台。

UDE模拟器调试效果图
 

下面就一起来看看该示例的实现代码吧。完整代码下载请见附件。

HTML结构代码

复制代码
代码如下:

<div class="center">
<ul>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
<li>
<div></div>
</li>
</ul>
</div>

CSS样式代码

复制代码
代码如下:

@keyframes bump {
0% {
opacity: 0;
left: 535px;
}
100% {
left: -10px;
opacity: 0;
}
10%, 85% {
opacity: 1;
}
}
@keyframes spin {
0%, 100% {
height: 20px;
top: 50px;
}
50% {
height: 100px;
top: 0;
}
}
body {
background: rgba(0, 0, 0, 0.2);
}
div.center {
text-align: center;
margin-top: 40px;
}
ul {
background-color: rgba(255, 255, 255, 0.4);
position: relative;
display: block;
padding: 0;
margin: auto;
width: 600px;
height: 10px;
list-style: none;
border-radius: 200px;
border: 5px solid rgba(255, 255, 255, 0.2);
margin-top: 100px;
box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.1);
}
ul li {
position: absolute;
margin-top: -55px;
}
ul li:nth-child(1) {
animation: bump 1.5s infinite;
animation-delay: 0.1s;
}
ul li:nth-child(1) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.1s;
background-color: rgba(120, 120, 120, 0.3);
}
ul li:nth-child(2) {
animation: bump 1.5s infinite;
animation-delay: 0.2s;
}
ul li:nth-child(2) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.2s;
background-color: rgba(120, 0, 0, 0.3);
}
ul li:nth-child(3) {
animation: bump 1.5s infinite;
animation-delay: 0.3s;
}
ul li:nth-child(3) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.3s;
background-color: rgba(120, 120, 0, 0.3);
}
ul li:nth-child(4) {
animation: bump 1.5s infinite;
animation-delay: 0.4s;
}
ul li:nth-child(4) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.4s;
background-color: rgba(0, 120, 0, 0.3);
}
ul li:nth-child(5) {
animation: bump 1.5s infinite;
animation-delay: 0.5s;
}
ul li:nth-child(5) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.5s;
background-color: rgba(0, 120, 120, 0.3);
}
ul li:nth-child(6) {
animation: bump 1.5s infinite;
animation-delay: 0.6s;
}
ul li:nth-child(6) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.6s;
background-color: rgba(0, 0, 120, 0.3);
}
ul li:nth-child(7) {
animation: bump 1.5s infinite;
animation-delay: 0.7s;
}
ul li:nth-child(7) div {
border-radius: 22px;
transform-origin: center;
position: absolute;
height: 60px;
width: 80px;
animation: spin 0.4s infinite;
animation-delay: 0.7s;
background-color: rgba(120, 0, 120, 0.3);
}

注:请自行在所需之处加上浏览器前缀(如:-webkit- 、 -moz-),否则将不能正常显示效果。 

源码下载请见附件
 
闪烁跳跃进度条.rar (1.6 KB)
更多精彩内容其他人还在看

2013年五大主流浏览器 HTML5 与 CSS3 兼容性大比拼

这篇文章主要介绍了2013年五大主流浏览器 HTML5 和 CSS3 兼容性大比拼,需要的朋友可以参考下
收藏 0 赞 0 分享

前端设计师需要了解的9个问题

这篇文章主要介绍了前端设计师需要了解的9个问题以及注意事项,非常的实用,是篇非常不错的文章,这里推荐给大家
收藏 0 赞 0 分享

CSS强制性换行的方法区别详解

自动换行问题,正常字符的换行是比较合理的,而连续的数字和英文字符常常将容器撑大,挺让人头疼,下面介绍的是CSS如何实现换行的方法对于div,p等块级元素正常文字的换行(亚洲文字和非亚洲文字)元素拥有默认的white-space:normal,当定义的宽度之后自动换行
收藏 0 赞 0 分享

CSS语义化命名方式及常用命名规则

本文搜集了一些CSS语义化命名方式以及命名规则。如有错误或不妥之处,敬请指出,欢迎你提出更好的建议,加插更多的命名规范。
收藏 0 赞 0 分享

ul li内容宽度的问题的解决方案

在IE6下只要我设置LI的宽度为auto,不论LI里面的内容多长,LI的宽度始终是100%,即UL的宽度(这里我已经写死了UL的宽度)。设置max-width也没用。高手们,在IE系列浏览器中如何使LI的宽度真正的随着内容增长而增长呢?像FF那样。
收藏 0 赞 0 分享

html5+css3气泡组件的实现

本文是html5+css3系列教程的第一篇,给大家讲述html5+css3实现气泡组件,讲解的十分的详细,这里推荐给大家,希望对大家能有所帮助
收藏 0 赞 0 分享

html5+css3之CSS中的布局与Header的实现

本文从CSS3的布局(CSS的布局的演化、CSS3盒模型-box-sizing、float布局中的bfc、Flexbox简介)Header布局的实现(float实现布局、Header js的实现)向我们展示了HTML5与CSS3的魅力。
收藏 0 赞 0 分享

一款恶搞头像特效的制作过程 利用css3和jquery

今天给大家介绍一款恶搞头像特效的制作过程,你可以把任意一张照片放到跳舞的漫画中,为他带上不同的帽子,让他翩翩起舞,下面我们一起来看一下制作过程和效果
收藏 0 赞 0 分享

大图片根据分辨率自适应宽度仍居中显示

一个1920*900的大图,在1024*768的分辨率下仍居中显示,如何做到这一点,下面是一个可行的解决方案
收藏 0 赞 0 分享

CSS3提交意见输入框样式代码

这个提交意见输入框,结构使用到了table,样式用的css3,包含了多方面的知识,比较适合新手朋友们
收藏 0 赞 0 分享
查看更多