如何在h2后放置固定宽度的居中边框底部?-Howtoplacecenteredborderbottomwithfixedwidthafterh2?
作者:多米音乐_34067977 | 来源:互联网 | 2023-05-17 09:12
Howtoplacecenteredborder-bottomwithfixedwidth(100px)afterh2(whichcanbelongerorshorte
How to place centered border-bottom
with fixed width (100px) after h2
(which can be longer or shorter depending on text)?
如何在h2之后放置具有固定宽度(100px)的居中边框底部(根据文本可以更长或更短)?
CODE
h2 {
position: relative;
z-index: 1;
text-align: center;
padding-bottom: 50px;
}
h2:after {
content: "";
position: absolute;
left: 50%;
bottom: 0;
width: 100px;
border-bottom: 2px solid magenta;
}
Something
I am trying to do following
我想做以下
Fiddle
3 个解决方案