【发布时间】:2019-09-03 09:19:08
【问题描述】:
似乎只有 Firefox 忽略了底部:0;宣言。即使我尝试将 h1:before 元素的高度设置为 100%,它也不会改变 Firefox 中的任何内容。
对此行为有任何解释吗?是否有任何解决方法?
.title {
position: absolute;
}
.title h1 {
position: relative;
display: inline;
color: #fff;
line-height: 0.8;
white-space: pre-wrap;
border-top: 0.3em solid #0089C0;
border-bottom: 0.1em solid #0089C0;
background-color: #0089C0;
}
.title h1:before {
content: "";
background-color: red;
display: inline-block;
width: 0.3em;
height: 100%;
padding-top: 0.1em;
position: absolute;
left: -0.3em;
top: 0;
}
.title h1:after {
background-color: #0089C0;
}
.title h1 span {
position: relative;
z-index: 1;
}
<div class="title">
<h1><span>Almost before <br>we knew it, we had <br>left the ground. </span></h1>
</div>
【问题讨论】:
-
从标题中删除
display:inline- 这不是必需的并解决了问题 - codepen.io/Paulie-D/pen/wZebNG -
感谢您的快速回复。在我的情况下,
display:inline是必需的。即使使用display:inline,有什么办法可以解决这个问题吗? -
请解释为什么它是必需的。从提供的代码来看,没有区别。
-
display: inline-block如果你真的需要它应该可以工作 inline.. -
也许使用其他类型的内联,例如
inline-block。
标签: html css firefox pseudo-element