gpt4 book ai didi

html - Bootstrap 4 网格行 - 图像未垂直对齐

转载 作者:太空宇宙 更新时间:2023-11-04 05:47:37 24 4
gpt4 key购买 nike

我有一行图像由于某种原因没有垂直对齐。如果我使用所有相同的图像,它看起来不错,但如果我用尺寸略有不同的不同图像替换它就不起作用。下面是一个示例:

enter image description here

这是我的 HTML 代码..注意我正在使用一些自定义 CSS 进行叠加,不确定这是否会导致问题

<div className="container">

<div className="row">

<div className="col-xl-12 mx-auto mb-3">
<h2 className="abouthead">Portfolio</h2>
</div>
</div>
<div className="row">
<div className="col-lg-4 col-md-12 mb-4">
<div
className="view overlay hm-black-strong"
data-toggle="modal"
data-target="#modal1"
>
<img
src="http://localhost:3002/images/dealmazing.JPG"
className="img-fluid"
alt="sample"
/>
<div className="p-2 bg-info text-white">Deals Website</div>
<div className="mask flex-center">
<p className="white-text">View Project</p>
</div>
</div>
</div>

<div className="col-lg-4 col-md-12 mb-4">
<div
className="view overlay hm-black-strong"
data-toggle="modal"
data-target="#modal2"
>
<img
src="http://localhost:3002/images/crypto-portal.JPG"
className="img-fluid"
alt="sample"
/>
<div className="p-2 bg-info text-white">
Cryptocurrency Portal
</div>
<div className="mask flex-center">
<p className="white-text">View Project</p>
</div>
</div>
</div>

<div className="col-lg-4 col-md-12 mb-4">
<div className="view overlay hm-black-strong">
<img
src="http://localhost:3002/images/dealmazing.JPG"
className="img-fluid"
alt="sample"
/>
<div className="p-2 bg-info text-white">Deals Website</div>
<div className="mask flex-center">
<p className="white-text">View Project</p>
</div>
</div>
</div>

</div>

//CSS

@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css);
@import url(https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.3/css/mdb.min.css);

.hm-gradient {
background-image: linear-gradient(to top, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%);
}
.darken-grey-text {
color: #2E2E2E;

最佳答案

您是否尝试过为图像指定高度?然后申请Object-Fit CSS属性(property)。

img {
object-fit: cover;
width: 400px;
height: 400px;
}

关于html - Bootstrap 4 网格行 - 图像未垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58584286/

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