【发布时间】:2020-08-26 19:04:15
【问题描述】:
我正在尝试使用以 ligne 为中心的附加箭头来为我的文本添加下划线。 这样做时,我无法在页面中居中文本。
.souligne {
line-height: 17px;
padding-bottom: 15px;
text-transform: uppercase;
border-bottom: 2px solid #00a7a8;
position: relative;
display: inline-block;
}
.souligne:before {
content: '\25bc';
position: absolute;
top: 100%;
left: 5em;
color: #00a7a8;
}
<h2 class="souligne" style="text-align:center;">THIS IS MY HEADER</h2>
执行此操作时文本未居中。
.souligne {
line-height: 17px;
padding-bottom: 15px;
text-transform: uppercase;
border-bottom: 2px solid #00a7a8;
position: relative;
display: inline-block;
}
.souligne:before {
content: '\25bc';
position: absolute;
top: 100%;
left: 5em;
color: #00a7a8;
}
<h2 class="souligne" style="text-align:center">THIS IS MY HEADER</h2>
<br>
<center><h2 class="souligne">THIS IS MY HEADER</h2></center>
所以当在 H2 中使用 style="text-align:center" 时,它不会使文本居中,它仅在使用 <center> 时才有效。
【问题讨论】:
-
找到了合适的解决方案。 stackoverflow.com/questions/45963746/…
-
寻求代码帮助的问题必须包含最短的代码以便在问题本身中包含重现它所必需的最好是Stack Snippet。见How to create a Minimal, Reproducible Example
-
感谢@Evgeny Veliky,这与我想要做的非常接近。
-
@Paulie_D 谢谢我看看