在 Bootstrap 警报中垂直对齐文本而不使用行高
我希望在 Bootstrap 4 警报中垂直对齐文本内容,最重要的是不使用line-height
,并且最好不使用绝对定位。
我的警报如下所示:
<div class="alert alert-info" role="alert">
Your free trial will expire on <b>23-May-2022</b>. To retain your subscription after this date you can <a href="/admin/crmpicco-gvb-trial/plan">upgrade</a> to one of our paid plans.
</div>
下面的我的 SCSS 声明确实有效:
.alert.alert-info {
border: 1px solid #0f6fc5;
background: #EAF2FA;
color: #212529;
min-height: 64px;
display: flex;
align-items: center;
}
但是,它删除了 和
标记周围的空格。
有没有办法解决这个问题,以尊重间距,而无需对 b
和 a
元素使用 hacky margin
解决方案?
I am looking to vertically align text content inside my Bootstrap 4 alerts, crucially without using line-height
and ideally without absolute positioning.
My alert looks like this:
<div class="alert alert-info" role="alert">
Your free trial will expire on <b>23-May-2022</b>. To retain your subscription after this date you can <a href="/admin/crmpicco-gvb-trial/plan">upgrade</a> to one of our paid plans.
</div>
My SCSS declaration below does work:
.alert.alert-info {
border: 1px solid #0f6fc5;
background: #EAF2FA;
color: #212529;
min-height: 64px;
display: flex;
align-items: center;
}
However, it removes the spacing around then <b>
and <a>
tags.
Is there a way to fix this to respect the spacing without a hacky margin
solution to the b
and a
elements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许将您的文本纳入跨度?这是你的意思吗?
maybe enlcosed your text to a span?? Is this what you mean?