移動web相簿——css3進度條

來源:互聯網
上載者:User

標籤:

1.介紹

因項目中上傳作品和web相簿都需要上傳,都需要用到進度條,進度條的實現可以用Falsh,圖片,javascript,但這裡我是在移動端使用,所以重點介紹css3的實現方法。

2.代碼展示
/*外層box*/        .progress_box{          height: 10px;          width:200px;          border-radius: 5px;          background-color:#ececec;        }        /* 動畫 */        @-webkit-keyframes progressbar {             from {                width:0            }            to {                width:100%            }        }        /* Standard syntax */        @keyframes progressbar {            from {                width:0            }            to {                width:100%            }        }        /*普通進度條*/        .bar1{            height:10px;            background:#4fd0bc;            width:0;            border-radius:5px;            -webkit-transition:width .10s ease;            transition:width .10s ease;            -webkit-animation:progressbar 10s infinite both;            animation:progressbar 10s infinite both;            /*這裡為了示範-webkit-animation-iteration-count設定為infinite*/        }        /*條紋進度條*/        .bar2{            width:0;            height:10px;            background:#4fd0bc;            border-radius:5px;            background-image:linear-gradient(-45deg,rgba(255,255,255,.5) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.6)       50%,rgba(255,255,255,.6) 75%,transparent 75%,transparent);            -webkit-transition:width .10s ease;            transition:width .10s ease;            -webkit-animation:progressbar 10s infinite both;            animation:progressbar 10s infinite both;        }

 

3.普通進度條
<div class="progress_box"><div class="bar1"></div></div>

 

4.條紋進度條
<div class="progress_box"><div class="bar2"></div></div>

 

5.html5實現進度條

上面的兩種方式都是使用div包裹,來實現的,但html5提供的一個新的屬性,不用嵌套包裹,一個屬性就搞定;

(1) progress

progress 元素屬於html5的新屬性,ie9(包括ie9)不支援

(2)基本屬性:

1.max 指最大值。若預設,進度值範圍從0.0~1.0,如果設定成max=100,則進度值範圍從0~100

2. value 進程的當前值

(3)預設效果如下:

(4)修改預設樣式,實現如上效果:
.pgs {    width: 200px;    border: 1px solid #ccc;      background-color:#ececec;    border-radius: 5px;    height: 10px;    border:none;}progress::-webkit-progress-bar {     background-color:#ececec;    border-radius: 5px;}progress::-webkit-progress-value{     background: #4fd0bc;     border-radius: 5px;}

 

<progress value="50" max="100" class="pgs"></progress>

 

這雷根據上傳進度,直接修改value值就ok了$("progress").val(precent);

移動web相簿——css3進度條

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.