gpt4 book ai didi

html - 在标题元素内添加水平线

转载 作者:太空宇宙 更新时间:2023-11-03 22:36:22 25 4
gpt4 key购买 nike

我想复制这个:

enter image description here

所以我试过这个:

.test {
position:relative;
width:100%;
margin:0 auto;

}

.test hr {
display:inline;
width:40%;
float:left;
border:2px solid black;
}

.test h1 {
display:inline;
float:right;
font-size:56px;
}
<div class="test">
<hr />
<h1>Here is how the magic <br/> works.</h1>

</div>

如您所见,还差得远。

我该怎么做?

最佳答案

一个内部 span,一个伪元素和 span 的背景颜色(您指定的始终为白色)

h1 {
width: 80%;
margin: 1em auto;
text-align: right;
position: relative;
overflow: hidden;
}

.narrow {
width: 50%;
}

.thin {
width: 50%;
font-size: 16px;
}

span {
background: white;
position: relative;
z-index: 2;
padding-left: ..5em;
}

h1::after {
content: "";
width: 100%;
height: 2px;
background: currentcolor;
position: absolute;
left: 0;
bottom: .5em;
}
<h1><span>This is how the magic works</span></h1>


<h1 class="narrow"><span>This is how the magic works</span></h1>

<h1 class="thin"><span>This is how the magic works, no really it does with any font-size!</span></h1>

关于html - 在标题元素内添加水平线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46368787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com