注册

纯CSS3实现动态进度条效果的代码

嗨豆壳技术文章 时间:2014-09-02 20:06:25 [ray]

在项目开发中,进度条经常使用到,比如:加载进度条,数据图表的进度条等。。。本文介绍如何使用纯CSS3实现动态进度条效果。

纯CSS3实现的动态加载进度条效果

实现多种效果动态加载进度条效果,css3实现此效果。

该效果的浏览器兼容:

IE11和IE11以下浏览器不完全支持此特效。

谷歌浏览器支持此特效,火狐浏览器支持此特效。

该效果的CSS样式

css样式代码比较长,不懂其中的含义也不要紧,复制直接使用就可以了。

* { margin: 0; padding: 0; }
body { font: 14px Georgia, serif;  }
#page-wrap { width: 490px; margin: 80px auto; }
.meter {
height: 20px;
position: relative;
background: #f7f7f7;
padding: 5px;
-webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
-moz-box-shadow   : inset 0 -1px 1px rgba(255,255,255,0.3);
box-shadow        : inset 0 -1px 1px rgba(255,255,255,0.3);
}
.meter > span {
display: block;
height: 100%;
background-color: rgb(43,194,83);
background-image: -webkit-gradient(
linear,left bottom,left top,
color-stop(0, rgb(43,194,83)),
color-stop(1, rgb(84,240,84))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(43,194,83) 37%,
rgb(84,240,84) 69%
);
-webkit-box-shadow:
inset 0 2px 9px  rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
-moz-box-shadow:
inset 0 2px 9px  rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
box-shadow:
inset 0 2px 9px  rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
position: relative;
overflow: hidden;
}
.meter > span:after, .animate > span > span {
content: "";
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background-image:
-webkit-gradient(linear, 0 0, 100% 100%,
color-stop(.25, rgba(255, 255, 255, .2)),
color-stop(.25, transparent), color-stop(.5, transparent),
color-stop(.5, rgba(255, 255, 255, .2)),
color-stop(.75, rgba(255, 255, 255, .2)),
color-stop(.75, transparent), to(transparent)
);
background-image:
-moz-linear-gradient(
-45deg,
rgba(255, 255, 255, .2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, .2) 50%,
rgba(255, 255, 255, .2) 75%,
transparent 75%,
transparent
);
z-index: 1;
-webkit-background-size: 50px 50px;
-moz-background-size: 50px 50px;
background-size: 50px 50px;
-webkit-animation: move 2s linear infinite;
-moz-animation: move 2s linear infinite;
overflow: hidden;
}
.animate > span{ transition: .3s;}
.animate > span:after {	display: none;}

@-webkit-keyframes move {
	0% {	background-position: 0 0;	}
	100% {	background-position: 50px 50px;	}
}

@-moz-keyframes move {
	0% {	background-position: 0 0;	}
	100% {	background-position: 50px 50px;	}
}
.red > span {
background-color: #f0a3a3;
background-image: -moz-linear-gradient(top, #f0a3a3, #f42323);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #f0a3a3),color-stop(1, #f42323));
background-image: -webkit-linear-gradient(#f0a3a3, #f42323);
}
效果示例
<div class="meter">
	<span style="width: 25%"></span>
</div>
<div class="meter orange nostripes">
	<span style="width: 33.3%"></span>
</div>
<div class="meter red">
	<span style="width: 80%"></span>
</div>

标签

本文地址:https://www.hi-docs.com/article/73.html

上一篇:php数组函数array_merge(),array_merge_recursive()解析

下一篇:linux date命令实现日期时间和Unix时间戳转换