【问题标题】:Center a DIV that contains images regardless of window size将包含图像的 DIV 居中,无论窗口大小如何
【发布时间】:2017-04-12 00:18:42
【问题描述】:

我有一个包含三张图片的 div,我想将它放在页面的中心(很像 Google 搜索栏)。我已经尝试过几乎所有东西(位置、边距等),但即使我把它放在一台显示器上,当我将它移到另一台显示器上时,它也不会以新显示器为中心。请帮忙!

这里是 HTML:

<div id="boxes">
    <a href="voting_registration.html" target="_blank"> <img src="images/VR.jpg" alt="Voting Registration Information" class="list" /></a>
    <a href="ballot.html" target="_blank"> <img src="images/PCB.jpg" alt="Platforms, Candidates and Ballots" class="list" /></a>
    <a href="voting_information.html" target="_blank"><img src="images/VI.jpg" alt="Voting Information" class="list"/> </a>
</div>

【问题讨论】:

标签: html css


【解决方案1】:

将此用于您的盒子的 css 代码:

margin: 0 auto;

0 是 margin-top,表示距离顶部 0 个像素,您可以更改它。

【讨论】:

  • 我会编辑这个答案,但编辑队列已满。你会考虑用正确的语法和格式来提高这个答案的质量吗?展示其工作原理的现场演示也将非常有帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-22
  • 1970-01-01
  • 2013-12-12
  • 2013-09-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多