gpt4 book ai didi

html - 居中图像的div

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

如何将包含 3 张图像的集合居中。我希望收藏集中在网页上。并排*。具有间距的并排图像集合。

.column {
float: left;
width: 30.00%;
padding: 5px;
}


/* Clear floats after image containers */

.row::after {
content: "";
clear: both;
display: table;
}
<div class="row">
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
</div>

最佳答案

使用 Flex 的最简单的解决方案。

.row{
display:flex;
justify-content:center; //This will get your images to center.
}

Images width is purposefully reduced to 20%.

.column {
width: 20.00%;
padding: 5px;
}


/* Clear floats after image containers */

.row::after {
content: "";
clear: both;
display: table;
}

.row {
display: flex;
justify-content: center;
}
<div class="row">
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
<div class="column">
<img src="https://cdn.pixabay.com/photo/2017/05/09/21/49/gecko-2299365_1280.jpg" alt="BullishTrade" style="width:100%">
</div>
</div>

确保检查browser Compatibility with Flexbox .它适用于大多数现代浏览器。

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

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