当我给出最大高度时,卡片图像宽度不相等 [英] Card image width not equal when I gave max-height
本文介绍了当我给出最大高度时,卡片图像宽度不相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一张具有相同图像尺寸和文字的卡片.
我已将max-height
赋予了图像.但图片大小不相等.
我将在下面给出我的代码.
我附上我的网站的快照,以获取更好的参考.
在此项目中,我正在使用 HTML,CSS和BOOTSTRAP4
I am making a card with equal image size and text.
I had given max-height
to the image. but the images are not equal in size.
I will give my code below.
I am attaching my website's snap for better reference.
In this project, I am using HTML, CSS and BOOTSTRAP4
问题是:图片
.kbcard {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 300px;
margin: auto;
text-align: center;
font-family: arial;
}
.kbtitle {
color: grey;
font-size: 18px;
}
a .kb{
text-decoration: none;
font-size: 22px;
color: black;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="row">
<div class="col-md-3">
<div class="kbcard">
<img src="https://www.saintleuparis.catholique.fr/IMG/arton691.jpg?1467978372" alt="John" style="max-width:300px">
<h1>John Doe</h1>
<p class="kbtitle">CEO & Founder, Example</p>
<p>Harvard University</p>
</div>
</div>
<div class="col-md-3">
<div class="kbcard">
<img src="https://www.saintleuparis.catholique.fr/local/cache-vignettes/L187xH270/images-74-b67fc.jpg?1468002198" alt="John" style="max-width:300px">
<h1>John Doe</h1>
<p class="kbtitle">CEO & Founder, Example</p>
<p>Harvard University</p>
</div>
</div>
</div>
我需要:捕捉
推荐答案
img {
vertical-align: middle;
border-style: none;
width: 100%;
height: 250px;
object-fit: cover;
}
尝试将这些样式应用于您的图片标签
try these stylings to your image tag
这篇关于当我给出最大高度时,卡片图像宽度不相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文