gpt4 book ai didi

html - 如何连续插入5张图片

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:26 26 4
gpt4 key购买 nike

我有 5 张图片:

图一:https://www.url.se/1
图二:https://www.url.se/2
图三:https://www.url.se/3
图四:https://www.url.se/4
图 5:https://www.url.se/5

每张图片的大小为:

图一:70x40
图二:80x42
图三:90x44
图 4:100x46
图 5:120x48

我想将这些图片并排插入一行。我还希望能够在 CSS 中调整这些图片之间的距离,以及顶部和底部边框。

如何创建一个 div 类并粘贴此代码以在页面上显示这些图片?另外,CSS 如何查找这个 div 类,我可以在其中调整图像之间的距离以及顶部和底部边框的距离

最佳答案

您可以使用 display: inlinefloat: left

  1. 显示:内联

*{box-sizing: bortder-box}  /*lang-css*/

figure{
width: 100%;
}
img{display: inline; margin: 0 10px; border-top: 2px solid red; border-bottom: 4px solid green}
img:first-child{width: 70px; height: 40px}
img:nth-child(2){width: 80px; height: 42px}
img:nth-child(3){width: 90px; height: 44px}
img:nth-child(4){width: 100px; height: 46px}
img:last-child{width: 120px; height: 48px}
<figure> <!--lang-html-->
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
</figure>

  1. float :左

*{box-sizing: bortder-box}  /*lang-css*/

figure{
width: 100%;
}
img{float: left; margin: 0 10px; border-top: 2px solid red; border-bottom: 4px solid green}
img:first-child{width: 70px; height: 40px}
img:nth-child(2){width: 80px; height: 42px}
img:nth-child(3){width: 90px; height: 44px}
img:nth-child(4){width: 100px; height: 46px}
img:last-child{width: 120px; height: 48px}
<figure> <!--lang-html-->
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
</figure>

您需要添加 text-align: center在父标签上,如果你想让它居中

*{box-sizing: bortder-box}  /*lang-css*/

figure{
text-align: center;
width: 100%;
}
img{margin: 0 10px; border-top: 2px solid red; border-bottom: 4px solid green}
img:first-child{width: 70px; height: 40px}
img:nth-child(2){width: 80px; height: 42px}
img:nth-child(3){width: 90px; height: 44px}
img:nth-child(4){width: 100px; height: 46px}
img:last-child{width: 120px; height: 48px}
<figure> <!--lang-html-->
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
<img src=https://pbs.twimg.com/media/B3bbgs9CMAA5Cwi.jpg />
</figure>

关于html - 如何连续插入5张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27916666/

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