此标签是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"
>
<
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"
>
<
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>标签用法介绍