標籤:
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進度條