这大致就是我要做的:通过border-bottom
在containing上设置a ,h2
然后再给h2
a small 来创建该行line- height
。然后将文本放在span
具有非透明背景的嵌套中。
h2 {
width: 100%;
text-align: center;
border-bottom: 1px solid #000;
line-height: 0.1em;
margin: 10px 0 20px;
}
h2 span {
background:#fff;
padding:0 10px;
}
<h2><span>THIS IS A TEST</span></h2>
<p>this is some content other</p>
我仅在Chrome中进行过测试,但是没有理由它不能在其他浏览器中运行。