gpt4 book ai didi

html - 在 div 中包含图像

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

我有 4 张尺寸为 500x500 的图片。我遇到的问题是最后一张图片超出了页面,造成了不必要的空间。我如何将它包含在跨越页面的范围内?

HTML:

<div id="collage">
<div class="row">

<div class="col-md-3">
<img src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg>
</div>

<div class="col-md-3">
<img src=https://www.roys.co.uk/media/wysiwyg/FASHION/MENSWEAR-AW16-JOULES-COAT.jpg>
</div>

<div class="col-md-3">
<img src=https://s-media-cache-ak0.pinimg.com/736x/b1/5e/38/b15e38cd4864c85a52897d906a88710c.jpg>
</div>

<div class="col-md-3">
<img src=https://static1.squarespace.com/static/56b6a4bd07eaa0d2d0eddb7f/58678682bebafb6e8b0a4e2a/5867868b893fc0dff9edd97d/1483179664063/Andrew+Belliot-011.jpg?format=500w>
</div>

</div>
</div>

CSS:

#collage img {
background-size: cover;
}

最佳答案

尝试添加 .img-responsive 类,如下所示:

<div id="collage">
<div class="row">

<div class="col-md-3">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/e6/61/fe/e661fe4b71debff151e6eb3fcd670bbe.jpg>
</div>

<div class="col-md-3">
<img class="img-responsive" src=https://www.roys.co.uk/media/wysiwyg/FASHION/MENSWEAR-AW16-JOULES-COAT.jpg>
</div>

<div class="col-md-3">
<img class="img-responsive" src=https://s-media-cache-ak0.pinimg.com/736x/b1/5e/38/b15e38cd4864c85a52897d906a88710c.jpg>
</div>

<div class="col-md-3">
<img class="img-responsive" src=https://static1.squarespace.com/static/56b6a4bd07eaa0d2d0eddb7f/58678682bebafb6e8b0a4e2a/5867868b893fc0dff9edd97d/1483179664063/Andrew+Belliot-011.jpg?format=500w>
</div>

</div>
</div>

关于html - 在 div 中包含图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43022783/

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