[英]Why does the default styling on a HTML5 <progress> bar have vertical-align?
Interesting question. 有趣的问题。 According to
vertical-align
documentation when the value is specified as a length then it 根据
vertical-align
文档,当值指定为长度时,它
Aligns the baseline of the element at the given length above the baseline of its parent.
将给定长度的元素基线与其父元素的基线对齐。
By default the height of the progress
element defined as 1em
. 默认情况下,
progress
元素的高度定义为1em
。 This means that making it -0.2em
ensures that progress bar stays perfectly alligned vertically with adjacent inline/inline-block elements. 这意味着使其成为
-0.2em
可确保进度条与相邻的内联/内联块元素保持完美-0.2em
。
var progress = document.querySelector('progress'); setInterval(function() { progress.classList.toggle('va0'); }, 2000);
body { font-size: 2em; } progress { width: 200px; } .va0 { vertical-align: 0; } div:after { position: absolute; top: 50px; content: '<progress> vertical-align: -0.2em'; } .va0 ~ div:after { content: '<progress> vertical-align: 0'; }
<progress></progress> Some text. <div></div>
Try making progress bar vertical-align: 0
and you will see that it no longer looks nice next to its inline neighbors. 尝试使进度条
vertical-align: 0
,你会看到它的内联邻居旁边看起来不再好看了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.