gpt4 book ai didi

html - 无法垂直居中 Bootstrap 3 媒体

转载 作者:行者123 更新时间:2023-11-28 01:01:20 34 4
gpt4 key购买 nike

我正在尝试将 Bootstrap 3 图像媒体对象居中放置在一行的左侧。因此,我使用 pull-left 使 CSS 将图像向左浮动,但尽管尝试了所有推荐的在线策略,我仍无法将此图像置于行本身的中心。

这是我正在谈论的代码片段:

https://jsfiddle.net/afoxprogramming/aq9Laaew/242135/

是否可以将这些占位符图像在其行中垂直居中,以便图像上方和下方的空间高度与各自行中的文本不同?下面是一些 html:

<div class="row">
<div class="col-xs-12">
<div class="media">
<img class="pull-left img-responsive index-page-list-image" src="https://via.placeholder.com/157x20"style="max-width: 33.33%">
<div class="media-body">
<p class=""><strong>Volunteering</strong></p>
<p>Test text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text.</p>
</div>
</div>
</div>
<div class="col-xs-12">
<div class="media">
<img class="pull-left img-responsive index-page-list-image" src="https://via.placeholder.com/300x100" style="max-width: 33.33%">
<div class="media-body">
<p class=""><strong>Volunteering</strong></p>
<p>Test text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text. est text. Test text. Test text. Test text. Test text. Test text.</p>
</div>
</div>
</div>
</div>

和相关的 CSS:

.index-page-list-image {
width: 100%;
}

最佳答案

只需删除 align-items: flex-start;并添加以下内容,您就完成了...

.media {
align-items: center;
}

关于html - 无法垂直居中 Bootstrap 3 媒体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52639648/

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