【发布时间】:2021-11-13 12:08:58
【问题描述】:
我在这里创建了一个网站,我应该将他们的名字放在他们的下方并居中。截图是here,但它们没有居中,在移动设备上看起来很奇怪。我也需要它来响应。我可以添加什么来解决这个问题?
我的 HTML:
<center>
<h1>Meet our officers!</h1>
</center>
<center>
<div class="main">
<figure>
<center><img src="boysmeettheofficers/Baha Abed.jpg" width="150" height="150" alt="missing"></center>
<center><figcaption>President</figcaption></center>
</figure>
<figure>
<img src="boysmeettheofficers/Adnan AL-Zoibi.jpg" width="150" height="150" alt="missing">
<figcaption>Vice President</figcaption>
</figure>
<figure>
<img src="boysmeettheofficers/Omar Ibrahim.jpg" width="150" height="150" alt="missing">
<figcaption>Secertary</figcaption>
</figure>
<figure>
<img src="boysmeettheofficers/Othman Al-Mesbah.jpg" width="150" height="150" alt="missing">
<figcaption>Historian</figcaption>
</figure>
<figure>
<img src="boysmeettheofficers/Salman Al-Estath.jpg" width="150" height="150" alt="missing">
<figcaption>Treasurer</figcaption>
</figure>
</div>
</center>
我的 CSS:
.main {
display: flex;
}
【问题讨论】:
-
'center' 是一个已弃用的元素,不应再使用。
-
知道我可以做什么吗?
-
@Mohammad 看起来图像本身在右侧有空白。见i.stack.imgur.com/jFznt.png。您需要将其裁剪掉,否则即使图像居中,右侧也会有空白区域。当我检查时,页面的标记与发布的标记不匹配,但是 display: flex 很好,请参阅css-tricks.com/snippets/css/a-guide-to-flexbox 以获得一些帮助(使主元素或父元素 100% 宽度、高度、对齐项:中心, justify-items:根据记忆居中)。
标签: javascript html css