gpt4 book ai didi

html - 如何水平对齐 3 张图像并将它们居中

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

我想知道如何将 3 张图像水平居中。我知道如何让它们水平对齐,但后来我失去了居中。所以我将图片水平排列,但我尽一切努力使它们居中,但没有任何效果。所以我真正想要的是中间的一个居中,另外两个在它的一侧,如果可以的话,间距均匀。

    <!DOCTYPE html>

<html>
<head>
<title>Anchor</title>
<link rel="stylesheet" href="main.css" type="text/css"/>
</head>
<body>
<div id="page">
<div id="header">

<h1 id="fhead">Used Clothes, Toys, and Micellaneous Items</h1>
<p> Choose from the three items below</p>
</div>
<div id="body">
<figure id="pic1">
<a href="Pages/clothes.html"><img src="Images/faker.jpg" height="" width="" alt="Clothes"></a>
<figcaption>Click picture to browse clothes</figcaption>
</figure>
<figure id="pic2">
<a href="Pages/toys.html"><img src="Images/faker.jpg" height="" width="" alt="Toy"></a>
<figcaption>Click picture to browse clothes</figcaption>
</figure>
<figure id="pic3">
<a href="Pages/miscellaneous.html">]
<img src="Images/faker.jpg" height="" width="" alt="Misc">
</a>
<figcaption>Click picture to browse clothes</figcaption>
</figure>
</div>
<div id="footer">

</div>
</div>
</body>

</html>

Here is the css:

#body {
position: relative;
width: 95%;
}
figure {
float: left;
text-decoration: none;
}
#pic3 {
position: absolute;
right: 0;
clear: left;
}

figcaption {
border: 1px solid red;
border-radius: 10px;
padding: 10px;
}


So I have the pictures lined up horizontally, but I tried everything to get them centered and nothing is really working. So what I really want is for the middle one to be centered and the other 2 to be on the side of it with even spacing if that makes since.

最佳答案

将它们全部放在 div 中,然后使该 div 居中。

关于html - 如何水平对齐 3 张图像并将它们居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32928903/

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