在Internet Explorer上的hr标记中,伪元素无法正常工作

Luc*_*uca 2 html css internet-explorer

以下代码适用于除Internet Explorer之外的所有浏览器.在IE中,措辞似乎被压缩到1px height或被hr渐变覆盖.是什么导致了这个问题?

.hr-how {
  text-align: center;
  border: 0;
  height: 1px;
  margin-bottom: 40px;
  margin-top: 40px;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
.hr-how:after {
  content: "HOW TO USE IT";
  display: inline-block;
  position: relative;
  top: -0.7em;
  font-size: 0.9em;
  padding: 0 0.6em;
  background: white;
}
Run Code Online (Sandbox Code Playgroud)
<hr class="hr-how" id="hr-how">
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/y8nx51rf/

Hid*_*bes 7

发生这种情况是因为overflowon hr标签的默认设置是visible在Chrome和Firefox中,但hidden在IE中.这使得外部的任何内容heighthr在IE被切断.

为了使这项工作在IE中添加overflow: visible;,.hr-how所以文本可以扩展到hr.

.hr-how {
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  border: 0;
  height: 1px;
  margin-bottom: 40px;
  margin-top: 40px;
  overflow: visible;
  text-align: center;
}
.hr-how:after {
  background: white;
  content: "HOW TO USE IT";
  display: inline-block;
  font: "BodoniXT" !important;
  font-size: 0.9em;
  padding: 0 0.6em;
  position: relative;
  top: -0.7em;
}
Run Code Online (Sandbox Code Playgroud)
<hr class="hr-how" id="hr-how" />
Run Code Online (Sandbox Code Playgroud)