在简单的 CSS 中是否可以仅在标题部分加下划线,特别是左侧的前 50 像素?
您可以使用:before
伪元素并为其添加边框。
h1 {
position: relative;
line-height: 1.2em;
}
h1:before {
position: absolute;
left: 0;
top: 1.2em;
height: 0;
width: 50px;
content: '';
border-top: 1px solid red;
}
<h1>This is a header, partly underlined</h1>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)