我正在使用以下代码生成水平条形图。在旧版本的浏览器中它可以运行,但在Internet Explorer 9中却不行。除非我点击“兼容性视图”,否则它不会可见。我们有替代方案吗?或者已经被取代了吗?
<hr style="color:#F87431 ; height:7px "/>
尝试一下
<hr style="background:#F87431; border:0; height:7px" />
HR的原始形式,像STRIKE、B等,太注重布局和展示。
HTML5正在将标记向更语义化的结构移动,更强调布局放置在CSS和媒体元素上。
来自W3C文档:
In HTML 4.01, the <hr> tag represented a horizontal rule.
In HTML5, the <hr> tag defines a thematic break.
However, the <hr> tag may still be displayed as a horizontal rule in visual browsers, but is now defined in semantic terms, rather than presentational terms.
所以你只需要将它漂亮地样式化。
我也使用 div 实现此效果,类似于 <div style="width: 100%; height: 7px; background: #F87431; overflow: hidden;">
<div style="color:#F87431;height:7px;">-------------------</div>
在这个阶段不要使用HR,因为它已经过时了,只在测试中使用内联CSS ;-)