HTML5中progress元素的简略理解及兼容性题目解析-
一、progress元素根本理解
1.根本见识
progress元素属于HTML5家族,指进度条。IE10+以及其他靠谱阅读器都支撑。
注释:Internet Explorer 9 以及更早的版本不支撑
2.根本属性
max, value, position, 以及labels.
(1)max指最大值。若缺省,进度值范畴从0.0~1.0,要是设定成max=100, 则进度值范畴从0~100.
(2)value就是值了,若max=100, value=50则进度正好一半。value属性的存在与否决议了progress进度条可否拥有肯定性。
比如说没有value,是不肯定的,因而IE10阅读器下其长相是个无穷轮回的虚点动画;
但是,一旦有了value属性(即便无值),如, 也被以为是肯定的,
(3)position是只读属性,目前进度的位置,就是value / max的值。要是进度条不肯定,则值为-1.
(4)labels也是只读属性,得到的是指向该progress元素的label元素们。例如document.querySelector("progress").labels,返回的就是HTMLCollection。
二、progress元素兼容性处置示例
css兼容代码
progress { display: inline-block; width: 160px;height: 20px; border: 1px solid #0064B4; background-color:#e6e6e6;color: #0064B4; /*IE10*/} /*ie6-ie9*/ progress ie {display:block;height: 100%;background: #0064B4; } progress::-moz-progress-bar { background: #0064B4; } progress::-webkit-progress-bar { background: #e6e6e6; } progress::-webkit-progress-value { background: #0064B4; }