<progress>标签用法介绍

此标签是HTML5新增,用来表示进度条。

既然是HTML5新增,当然具有一定的兼容性问题,主要存在于低版本的IE浏览器,IE10+浏览器支持此标签。

代码实例如下:

 
 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!doctype html>
< html >
< head >
< meta charset = "utf-8" >
< meta name = "author" content = "http://www.softwhy.com/" />
< title >蚂蚁部落</ title
< style >    
progress {  
   display:inline-block;  
   width: 160px;  
   height: 20px;  
   border: 1px solid #0064B4;    
   background-color:#e6e6e6;  
   color: #0064B4; /*IE10*/ 
}   
progress::-moz-progress-bar { background: #0064B4; }  
progress::-webkit-progress-bar { background: #e6e6e6; }  
progress::-webkit-progress-value  { background: #0064B4; }    
</ style >    
</ head >    
< body >    
< progress max = "100" value = "20" ></ progress
</ body >    
</ html >

使用progress-bar属性可以设置进度条进度的样式。下面介绍一下此标签的相关属性:

(1).max:表示进度的最大值。

(2).value:表示进度的当前值。

在js操作中,position属性可以获取当前进度条的位置,也就是value/max,代码实例如下:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!doctype html>
< html >
< head >
< meta charset = "utf-8" >
< meta name = "author" content = "http://www.softwhy.com/" />
< title >蚂蚁部落</ title
< style >    
progress {  
   display:inline-block;  
   width: 160px;  
   height: 20px;  
   border: 1px solid #0064B4;    
   background-color:#e6e6e6;  
   color: #0064B4; /*IE10*/ 
}   
progress::-moz-progress-bar { background: #0064B4; }  
progress::-webkit-progress-bar { background: #e6e6e6; }  
progress::-webkit-progress-value  { background: #0064B4; }    
</ style
< script >
window.onload=function(){
   var opr=document.getElementById("pr");
   var oshow=document.getElementById("show");
   oshow.innerHTML=opr.position;
}
</ script >  
</ head >    
< body >    
< progress id = "pr" max = "100" value = "20" ></ progress >
< div id = "show" ></ div >
</ body >    
</ html >




原文发布时间为:2017-3-6

本文作者:admin

本文来自云栖社区合作伙伴“蚂蚁部落”,了解相关信息可以关注蚂蚁部落

原文链接:<progress>标签用法介绍

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值