一款基于jquery带百分比的响应式进度加载条
今天要给大家带来一款基于jquery带百分比的响应式进度加载条。这款加载条非常漂亮,而且带有进度的百度比,且在不同的百分比用的是不同的颜色。而且这款加载条采用了响应式设计,在不同的分辨率的显示器下完美支持。一起看下效果图吧。
实现的代码。
html代码:
- <h1>
- Battle.net <b>style progress bar</b></h1>
- <div class="progress">
- <b class="progress__bar"><span class="progress__text">Progress: <em>0%</em> </span>
- </b>
- </div>
css代码:
- .progress {
- font-size: 1.2em;
- height: 20px;
- background: rgba(255, 255, 255, 0.05);
- border-radius: 2px;
- border: 1px solid rgba(255, 255, 255, 0.2);
- }
- .progress--active .progress__bar {
- opacity:;
- }
- .progress__text {
- width: 20em;
- padding: 0 0.9em;
- position: absolute;
- }
- .progress__text em {
- font-style: normal;
- }
- .progress__bar {
- color: white;
- font-size: 12px;
- font-weight: normal;
- text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
- line-height: 19px;
- display: block;
- position: relative;
- top: -1px;
- left: -1px;
- width: 0%;
- height: 100%;
- opacity:;
- border: 1px solid;
- border-radius: 2px 0 0 2px;
- background-size: 100px 30px, 130px 30px, 130px 30px;
- background-position: -20% center, right center, left center;
- background-repeat: no-repeat, no-repeat, no-repeat;
- -webkit-transition: opacity 0.2s ease, width 0.8s ease-out, background-color 1s ease, border-color 0.3s ease, box-shadow 1s ease;
- transition: opacity 0.2s ease, width 0.8s ease-out, background-color 1s ease, border-color 0.3s ease, box-shadow 1s ease;
- -webkit-animation: pulse 2s ease-out infinite;
- animation: pulse 2s ease-out infinite;
- background-color: rgba(201, 4, 20, 0.95);
- background-image: -webkit-linear-gradient(0deg, rgba(226, 4, 22, 0) 10%, rgba(250, 6, 26, 0.8) 30%, #fb1f31 70%, rgba(250, 6, 26, 0.8) 80%, rgba(226, 4, 22, 0) 90%), -webkit-linear-gradient(left, rgba(251, 31, 49, 0) 0%, #fb1f31 100%), -webkit-linear-gradient(right, rgba(251, 31, 49, 0) 0%, #fb1f31 100%);
- background-image: linear-gradient(90deg, rgba(226, 4, 22, 0) 10%, rgba(250, 6, 26, 0.8) 30%, #fb1f31 70%, rgba(250, 6, 26, 0.8) 80%, rgba(226, 4, 22, 0) 90%), linear-gradient(to right, rgba(251, 31, 49, 0) 0%, #fb1f31 100%), linear-gradient(to left, rgba(251, 31, 49, 0) 0%, #fb1f31 100%);
- border-color: #fb3848;
- box-shadow: 0 0 0.6em #fa061a inset, 0 0 0.4em #e20416 inset, 0 0 0.5em rgba(201, 4, 20, 0.5), 0 0 0.1em rgba(254, 206, 210, 0.5);
- }
- .progress__bar--orange {
- background-color: rgba(201, 47, 0, 0.95);
- background-image: -webkit-linear-gradient(0deg, rgba(227, 53, 0, 0) 10%, rgba(252, 59, 0, 0.8) 30%, #ff4d17 70%, rgba(252, 59, 0, 0.8) 80%, rgba(227, 53, 0, 0) 90%), -webkit-linear-gradient(left, rgba(255, 77, 23, 0) 0%, #ff4d17 100%), -webkit-linear-gradient(right, rgba(255, 77, 23, 0) 0%, #ff4d17 100%);
- background-image: linear-gradient(90deg, rgba(227, 53, 0, 0) 10%, rgba(252, 59, 0, 0.8) 30%, #ff4d17 70%, rgba(252, 59, 0, 0.8) 80%, rgba(227, 53, 0, 0) 90%), linear-gradient(to right, rgba(255, 77, 23, 0) 0%, #ff4d17 100%), linear-gradient(to left, rgba(255, 77, 23, 0) 0%, #ff4d17 100%);
- border-color: #ff6030;
- box-shadow: 0 0 0.6em #fc3b00 inset, 0 0 0.4em #e33500 inset, 0 0 0.5em rgba(201, 47, 0, 0.5), 0 0 0.1em rgba(255, 214, 201, 0.5);
- }
- .progress__bar--yellow {
- background-color: rgba(232, 158, 0, 0.95);
- background-image: -webkit-linear-gradient(0deg, rgba(255, 174, 2, 0) 10%, rgba(255, 183, 28, 0.8) 30%, #ffbf36 70%, rgba(255, 183, 28, 0.8) 80%, rgba(255, 174, 2, 0) 90%), -webkit-linear-gradient(left, rgba(255, 191, 54, 0) 0%, #ffbf36 100%), -webkit-linear-gradient(right, rgba(255, 191, 54, 0) 0%, #ffbf36 100%);
- background-image: linear-gradient(90deg, rgba(255, 174, 2, 0) 10%, rgba(255, 183, 28, 0.8) 30%, #ffbf36 70%, rgba(255, 183, 28, 0.8) 80%, rgba(255, 174, 2, 0) 90%), linear-gradient(to right, rgba(255, 191, 54, 0) 0%, #ffbf36 100%), linear-gradient(to left, rgba(255, 191, 54, 0) 0%, #ffbf36 100%);
- border-color: #ffc74f;
- box-shadow: 0 0 0.6em #ffb71c inset, 0 0 0.4em #ffae02 inset, 0 0 0.5em rgba(232, 158, 0, 0.5), 0 0 0.1em rgba(255, 248, 232, 0.5);
- }
- .progress__bar--green {
- background-color: rgba(0, 178, 23, 0.95);
- background-image: -webkit-linear-gradient(0deg, rgba(0, 203, 26, 0) 10%, rgba(0, 229, 30, 0.8) 30%, #00fe21 70%, rgba(0, 229, 30, 0.8) 80%, rgba(0, 203, 26, 0) 90%), -webkit-linear-gradient(left, rgba(0, 254, 33, 0) 0%, #00fe21 100%), -webkit-linear-gradient(right, rgba(0, 254, 33, 0) 0%, #00fe21 100%);
- background-image: linear-gradient(90deg, rgba(0, 203, 26, 0) 10%, rgba(0, 229, 30, 0.8) 30%, #00fe21 70%, rgba(0, 229, 30, 0.8) 80%, rgba(0, 203, 26, 0) 90%), linear-gradient(to right, rgba(0, 254, 33, 0) 0%, #00fe21 100%), linear-gradient(to left, rgba(0, 254, 33, 0) 0%, #00fe21 100%);
- border-color: #19ff37;
- box-shadow: 0 0 0.6em #00e51e inset, 0 0 0.4em #00cb1a inset, 0 0 0.5em rgba(0, 178, 23, 0.5), 0 0 0.1em rgba(178, 255, 188, 0.5);
- }
- .progress__bar--blue {
- background-color: rgba(18, 135, 204, 0.95);
- background-image: -webkit-linear-gradient(0deg, rgba(20, 151, 227, 0) 10%, rgba(37, 162, 236, 0.8) 30%, #3dacee 70%, rgba(37, 162, 236, 0.8) 80%, rgba(20, 151, 227, 0) 90%), -webkit-linear-gradient(left, rgba(61, 172, 238, 0) 0%, #3dacee 100%), -webkit-linear-gradient(right, rgba(61, 172, 238, 0) 0%, #3dacee 100%);
- background-image: linear-gradient(90deg, rgba(20, 151, 227, 0) 10%, rgba(37, 162, 236, 0.8) 30%, #3dacee 70%, rgba(37, 162, 236, 0.8) 80%, rgba(20, 151, 227, 0) 90%), linear-gradient(to right, rgba(61, 172, 238, 0) 0%, #3dacee 100%), linear-gradient(to left, rgba(61, 172, 238, 0) 0%, #3dacee 100%);
- border-color: #54b6f0;
- box-shadow: 0 0 0.6em #25a2ec inset, 0 0 0.4em #1497e3 inset, 0 0 0.5em rgba(18, 135, 204, 0.5), 0 0 0.1em rgba(225, 242, 252, 0.5);
- }
- .progress__bar:before, .progress__bar:after {
- content: "";
- position: absolute;
- right: -1px;
- top: -10px;
- width: 1px;
- height: 40px;
- }
- .progress__bar:before {
- width: 7px;
- right: -4px;
- background: -webkit-radial-gradient(center, ellipse, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 75%);
- background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 75%);
- }
- .progress__bar:after {
- background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 25%, rgba(255, 255, 255, 0.3) 75%, rgba(255, 255, 255, 0) 100%);
- background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 25%, rgba(255, 255, 255, 0.3) 75%, rgba(255, 255, 255, 0) 100%);
- }
- .progress--complete .progress__bar {
- -webkit-animation: none;
- animation: none;
- border-radius: 2px;
- }
- .progress--complete .progress__bar:after, .progress--complete .progress__bar:before {
- opacity:;
- }
- @-webkit-keyframes pulse {
- 0% {
- background-position: -50% center, right center, left center;
- }
- 100% {
- background-position: 150% center, right center, left center;
- }
- }
- @keyframes pulse {
- 0% {
- background-position: -50% center, right center, left center;
- }
- 100% {
- background-position: 150% center, right center, left center;
- }
- }
- body, html {
- color: white;
- padding: 20px 50px;
- background: #131c23;
- font-family: Roboto;
- }
- h1 {
- font-weight:;
- line-height: 1em;
- margin: 0.5em 0;
- }
- h1 b {
- font-weight:;
- }
js代码:
- var $progress = $(".progress"),
- $bar = $(".progress__bar"),
- $text = $(".progress__text"),
- percent = 0,
- update,
- resetColors,
- speed = 200,
- orange = 30,
- yellow = 55,
- green = 85,
- timer;
- resetColors = function () {
- $bar
- .removeClass("progress__bar--green")
- .removeClass("progress__bar--yellow")
- .removeClass("progress__bar--orange")
- .removeClass("progress__bar--blue");
- $progress
- .removeClass("progress--complete");
- };
- update = function () {
- timer = setTimeout(function () {
- percent += Math.random() * 1.8;
- percent = parseFloat(percent.toFixed(1));
- $text.find("em").text(percent + "%");
- if (percent >= 100) {
- percent = 100;
- $progress.addClass("progress--complete");
- $bar.addClass("progress__bar--blue");
- $text.find("em").text("Complete");
- } else {
- if (percent >= green) {
- $bar.addClass("progress__bar--green");
- }
- else if (percent >= yellow) {
- $bar.addClass("progress__bar--yellow");
- }
- else if (percent >= orange) {
- $bar.addClass("progress__bar--orange");
- }
- speed = Math.floor(Math.random() * 900);
- update();
- }
- $bar.css({ width: percent + "%" });
- }, speed);
- };
- setTimeout(function () {
- $progress.addClass("progress--active");
- update();
- }, 1000);
- $(document).on("click", function (e) {
- percent = 0;
- clearTimeout(timer);
- resetColors();
- update();
- }); //@ sourceURL=pen.js
注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/7781
一款基于jquery带百分比的响应式进度加载条的更多相关文章
- 一款基于jquery和css3的响应式二级导航菜单
今天给大家分享一款基于jquery和css3的响应式二级导航菜单,这款导航是传统的基于顶部,鼠标经过的时候显示二级导航,还采用了当前流行的响应式设计.效果图如下: 在线预览 源码下载 实现的代码. ...
- 一款由jquery实现的超炫的页面加载特效
今天为大家带来一款由jquery实现的超炫的页面加载特效.连续的几个页面分开特效.最后由三维的线条由远至近消失,然后由近至远出现.效果超级梦炫.一起看下效果图: 在线预览 源码下载 实现的代码. ...
- 一款基于jQuery带事件记录的日历插件
之前我们也已经分享过不少jQuery日历插件,有些应用了CSS3的特性,外观就特别漂亮.今天要分享的这款jQuery日历插件不仅有着绚丽的外观,而且带有日期事件记录功能,点击日期即可展开事件记录窗口, ...
- 一款纯css3实现的条纹加载条
之前为大家带来了很多加载动画. 基于prefixfree.js的进度加载条 ,基于jquery带百分比的响应式进度加载条.今天给大家分享一款纯css3实现的条纹加载条.带有响应式的效果.效果图如下 : ...
- 基于jQuery带备忘录功能的日期选择器
今天给大家分享一款基于jQuery带备忘录功能的日期选择器.这款日期控制带有备记忘录功能.有备忘录的日期有一个圆圈,单击圆圈显示备忘录.该实例适用浏览器:360.FireFox.Chrome.Safa ...
- 基于jQuery带标题的图片3D切换焦点图
今天给大家分享一款基于jQuery带标题的图片3D切换焦点图.这款焦点图适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗. 实现的代码. htm ...
- 一款基于jQuery外观优雅带遮罩弹出层对话框
今天我们要来分享一款基于jQuery的弹出层对话框插件,该插件包含多种对话框类型,比如提示框.确认框等.更为实用的是,这款jQuery对话框中的按钮事件也可以被我们所捕获,从而相应对话框按钮的各种事件 ...
- 一款基于jQuery的带Tooltip表单验证的注册表单
今天给大家分享一款基于jQuery的注册表单,这款注册表单的特点是确认提交注册信息时,表单会自动验证所填写的信息,如果信息填写有误,即会在相应的字段内以Tooltip提示框的形式显示错误信息.这款jQ ...
- 10款基于jquery的web前端动画特效
1.jQuery横向手风琴图片切换动画 之前我们为大家分享过很多款基于jQuery和CSS3的手风琴菜单和手风琴焦点图插件,比如CSS3响应式垂直手风琴菜单和jQuery横向手风琴图片展示插件.今天要 ...
随机推荐
- java Properties的用法
Properties是一个特殊的Map,因为和IO流牵扯到了一块…… import java.io.BufferedReader;import java.io.File;import java.io. ...
- 【redis】常用命令
三.常用命令 1)连接操作命令 quit:关闭连接(connection) auth:简单密码认证 help cmd: 查看cmd帮助,例如:help quit ...
- 2016年度GitHub上Stars最多的10个项目
来源于:https://zhuanlan.zhihu.com/p/24627923 2016年接近尾声,在最近的几篇文章中,会整理总结一些2016年度开源项目.今天整理的是:2016年度GitHub最 ...
- java多线程(二)之实现Runnable接口
一.java多线程方式2: 实现Runnable接口 好处:a. 可以避免由于java单继承带来的局限性. b. 适合多个相同的程序的代码去处理同一个资源的情况, 把线程与程序的代码, 数据有效分离, ...
- Microsoft Office2003打开office2007文件的补丁
Microsoft office2003打开office2007,不需要安装2007,只需要装一个补丁即可 搜索:office2003打开office2007文件的补丁
- 使用ajax和window.history.pushState无刷新改变页面内容和地址栏URL (转)
在访问现在很火的google plus时,细心的用户也许会发现页面之间的点击是通过ajax异步请求的,同时页面的URL发生了了改变.并且能够很好的支持浏览器的前进和后退.不禁让人想问,是什么有这么强大 ...
- Fusion Tables 图层用于呈现 Google Fusion Tables 中包含的数据
Google Maps API 允许您使用 FusionTablesLayer 对象将 Google Fusion Tables 中包含的数据呈现为地图上的图层.Google Fusion Table ...
- 《java设计模式》之责任链模式
在阎宏博士的<JAVA与模式>一书中开头是这样描述责任链(Chain of Responsibility)模式的: 责任链模式是一种对象的行为模式.在责任链模式里,很多对象由每一个对象对其 ...
- A class file was not written. The project may be inconsistent, if so try refreshing this project and building it. eclipse提示错误
感觉很奇怪,查看了一下磁盘,发现workspace所在磁盘已经满了,删除一些文件之后,选择项目->Project->Clean...->选择Clean all projects-&g ...
- android 布局权重问题(最近布局经常坑爹)
android 布局 权重 With layout_weight you can specify a size ratio between multiple views. E.g. you have ...