Js 百分比进度条

【构想】

      CSS3 + JS

      CSS3控制进度

        利用CSS3中的 @keyframes

      JS实现百分比

        根据CSS来调整,时间

【页面代码】

  

  CSS代码

  

body {
        background-color: #f5f7f9;
        color: #6c6c6c;
        font: 300 1em/1.5em;
    }

    .container {
        left: 50%;
        position: absolute;
        top: 40%;
        transform: translate(-50%, -50%);
        -webkit-transform: translate(-50%, -50%);
    }
    /* PROGRESS */

    .progress {
        background-color: #e5e9eb;
        height: 0.25em;
        position: relative;
        width: 24em;
    }

    #progress-bar {
        animation-duration: 3s;
        animation-name: width;
        background-image: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);
        background-image: -webkit-linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);
        background-size: 24em 0.25em;
        height: 100%;
        position: relative;
    }

    @keyframes width {
        0%,
        100% {
            transition-timing-function: cubic-bezier(1, 0, 0.65, 0.85);
        }
        0% {
            width: 0;
        }
        100% {
            width: 100%;
        }
    }

    .container .notice {
        animation: change 5s linear 0s infinite;
        font-size: 15px;
        margin: 10px;
    }

    @keyframes change {
        0% {
            color: #4cd964;
        }
        25% {
            color: #5ac8fa;
        }
        50% {
            color: #007aff;
        }
        75% {
            color: #5856d6;
        }
        100% {
            color: #ff2d55;
        }
    }

  HTML代码

<div class="container">
        <div class="notice"id="notice">
            奴家,正在~客官不要急啦~(づ ̄ 3 ̄)づ
        </div>
        <div class="progress">
            <div id="progress-bar">
            </div>
        </div>
  </div>

   JS代码

  window.onload = function() {
            var progressBar = {
                //初始化
                init: function() {
                    var oBar = document.getElementById(‘progress-bar‘);
                    var oNotice = document.getElementById(‘notice‘);
                    var count = 0;
                    //百分比计算,根据css的来
                    var timer = setInterval(function() {
                        count++;
                        oBar.innerHTML = count + ‘%‘;
                        if (count === 100) {
                            oNotice.innerHTML = ‘客官,奴家好了~(????)‘
                            clearInterval(timer);
                        }
                    }, 30);
                }
            };
            progressBar.init();
        }

原文地址:https://www.cnblogs.com/wangyang0210/p/9536861.html

时间: 2024-08-01 21:56:16

Js 百分比进度条的相关文章

JS框架_(JQbar.js)柱状图动态百分比进度条特效

柱状图动态百分比进度条效果 <html> <head> <title>jqbar.js柱状图动态百分比进度条特效</title> <link href="css/demo.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="css/jqbar.css" /

css3圆形百分比进度条的实现原理

原文地址:css3圆形百分比进度条的实现原理 今天早上起来在查看jquery插件机制的时候,一不小心点进了css3圆形百分比进度条的相关文章,于是一发不可收拾,开始折腾了... 关于圆形圈的实现,想必用2个圆心相同,半径不同的div即可实现.大圆的颜色即为圆形进度条的底色,小圆的颜色即为中间百分比的遮罩颜色白色,还要加上左右2边一边一个半圆,也就是说总共应该有4个div,一个大圆的div中包含3个div,左右一边半个圆,遮罩div处于最上面. 那这里的一边半个圆怎么实现呢?使用css的clip属

HTML5圆形百分比进度条插件circleChart(记录)

介绍:一款可以描绘圆圈进度条的jQuery插件(可用作统计图) circleChart使用方法 在页面中引入jquery和circleChart.min.js文件. <script src="path/to/jquery.min.js"></script> <script src="path/to/circleChart.min.js"></script> HTML结构 使用一个<div>元素作为该圆形百分

js控制进度条到达100%跳转界面一

进度条一般在手机上用到的比较广泛,刚好最近的项目也是一直在做手机站,这个特效是手机端的一个界面,现在我把改成pc端了,进度条的快慢速度和样式可自行调节,改动也是很方便的,不多说,看代码: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>js控制进度条到达100%跳转界面</title></head>

使用ajax实现简单的带百分比进度条

需求:当进行文件长传保存等操作时,能在页面显示一个带百分比的进度条,给用户一个好的交互体验 实现步骤 JSP页面 1.添加table标签 <table id="load" width="700" border="0" align="center" bgcolor="#FAFAFA" cellpadding="0" cellspacing="0" borderco

143行js顶部进度条最小插件-nanobar.js源码解析

网页顶部进度条插件的有四五种,基本原理就是动态地创建一个元素,然后通过设置它的width来实现动画效果,width增长到达指定位置时,将其去掉.来看看nanobar.js作者jacoborus是怎么做到的吧! /* http://nanobar.micronube.com/ || https://github.com/jacoborus/nanobar/ MIT LICENSE */ (function (root) { 'use strict' // container styles var

百分比进度条

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="

js 实现进度条功能。

/** * 纯js进度条 * Created by kiner on 15/3/22. */ function progress(options){ this.w = (options && options.width)?parseFloat(options.width) : parseFloat(this.options.width); this.h = (options && options.height)?parseFloat(options.height) : pa

JS实现 进度条 不用控件 超级简单

http://www.jb51.net/article/61113.htm(转载出处) setTimeout和clearTimeou 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 <html> <head> <title>进度条</title> <style type