日期:2014-04-28  浏览次数:23706 次

文章简介:今天为大家带来另一款更具个性化的进度条:CSS3闪烁跳跃的进度条。

今天为大家带来另一款更具个性化的进度条:CSS3闪烁跳跃的进度条。

这个示例的原理和以前的都是一样的,都是通过大量的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)版本以下是不支持的。下面就一起来看看该示例的实现代码吧,完整的代码可下载附件查看。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS3闪烁跳跃的进度条Demos</title>
<style>
@-webkit-keyframes bump {
 0% {
 opacity: 0;
 left: 535px;
}
 100% {
 left: -10px;
 opacity: 0;
}
 10%, 85% {
 opacity: 1;
}
}
 @-moz-keyframes bump {
 0% {
 opacity: 0;
 left: 535px;
}
 100% {
 left: -10px;
 opacity: 0;
}
 10%, 85% {
 opacity: 1;
}
}
 @-ms-keyframes bump {
 0% {
 opacity: 0;
 left: 535px;
}
 100% {
 left: -10px;
 opacity: 0;
}
 10%, 85% {
 opacity: 1;
}
}
 @keyframes bump {
 0% {
 opacity: 0;
 left: 535px;
}
 100% {
 left: -10px;
 opacity: 0;
}
 10%, 85% {
 opacity: 1;
}
}
 @-webkit-keyframes spin {
 0%, 100% {
 height: 20px;
 top: 50px;
}
 50% {
 height: 100px;
 top: 0;
}
}
 @-moz-keyframes spin {
 0%, 100% {
 height: 20px;
 top: 50px;
}
 50% {
 height: 100px;
 top: 0;
}
}
 @-ms-keyframes spin {
 0%, 100% {
 height: 20px;
 top: 50px;
}
 50% {
 height: 100px;
 top: 0;
}
}
 @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;
 -webkit-border-radius: 200px;
 -moz-border-radius: 200px;
 -ms-border-radius: 200px;
 -o-border-radius: 200px;
 border-radius: 200px;
 border: 5px solid rgba(255, 255, 255, 0.2);
 margin-top: 100px;
 -webkit-box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.1);
 -moz-box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.1);
 box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.1);
}
ul li {
 position: absolute;
 margin-top: -55px;
}
ul li:nth-child(1) {
 -webkit-animation: bump 1.5s infinite;
 -moz-animation: bump 1.5s infinite;
 -o-animation: bump 1.5s infinite;
 animation: bump 1.5s infinite;
 -webkit-animation-delay: 0.1s;
 -moz-anima