只有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>
答案 0 :(得分:0)
像这样将.title h1
设置为display: inline-block;
:
.title h1 {
position: relative;
display: inline-block;
}
或者...像这样将position
设置为fixed
:
.title h1 {
position: fixed;
display: inline;
}