gpt4 book ai didi

html - bootstrap css 文本不垂直对齐

转载 作者:行者123 更新时间:2023-11-28 17:11:53 25 4
gpt4 key购买 nike

我正在创建一个水平计数器来标记您当前正在处理的步骤。我们使用 bootstrap 4。css 在没有 bootstrap 的情况下工作,但是当我将它添加到元素中时,它没有垂直对齐。文字在圆圈下方。

enter image description here

数字应在圆圈内垂直和水平居中。

如何让这个 css 在引导元素中工作?

HTML

.steps {
margin: auto;
text-align: center;
font-size: 40px;
text-align: center !important;
vertical-align: middle !important;
}

.steps div{
display: inline-block;
}

.steps .circle {
border-radius:100px;
width: 75px;
height: 75px;
text-align: center !important;
vertical-align: middle !important;
line-height: 75px;
}

.steps .separator {
width: 100px;
margin:0px -5px 0px -5px;
vertical-align: middle !important;
}

.steps .done {
color:#35FF8B;
}

.steps .done .circle {
border:3px solid #35FF8B;
background:#385463;
}

.steps .done .separator {
border:4px solid #35FF8B;
}
<div class="steps">
<div class="done">
<div class="circle">
1
</div>
<div class="separator"></div>
</div>
</div>

最佳答案

您还可以使用 line-height 执行此操作...删除填充并添加 width:75pxheight: 75px;line-height:75px ;

.steps {
margin: auto;
text-align: center;
font-size: 40px;
text-align: center !important;
vertical-align: middle !important;
}

.steps div{
display: inline-block;
}

.steps .circle {
border-radius:100px;
width: 75px;
height: 75px;
text-align: center !important;
vertical-align: middle !important;
line-height: 75px;
}

.steps .separator {
width: 100px;
margin:0px -5px 0px -5px;
vertical-align: middle !important;
}

.steps .done {
color:#35FF8B;
}

.steps .done .circle {
border:3px solid #35FF8B;
background:#385463;
}

.steps .done .separator {
border:4px solid #35FF8B;
}
<div class="steps">
<div class="done">
<div class="circle">
1
</div>
<div class="separator"></div>
</div>
</div>

关于html - bootstrap css 文本不垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45388491/

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