2017-04-11 127 views
1

我有一个包含三个图像的div,我想将它居中放置在页面的中心(很像Google搜索栏)。我尝试过几乎所有的东西(位置,边距等),但是即使我把它放在一台显示器上,当我将它移动到不同的显示器时,它也不会集中在新显示器上。请帮忙!居中包含图像的DIV,无论窗口大小如何

下面是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> 
+0

[Flexbox:水平和垂直居中]的可能重复(http://stackoverflow.com/questions/19026884/flexbox-center-horizo​​ntally-and-vertically) –

+0

[居中响应div与图像内部]的可能重复( http://stackoverflow.com/questions/34408145/centering-responsive-divs-with-images-inside)以及通过搜索搜索到的其他众多答案。 – Rob

回答

-1

利用你的箱子的CSS代码:

margin: 0 auto; 

0边距,意味着从顶部0像素,并可以改变这种状况。

+0

我会编辑此答案,但编辑队列已满。你会考虑用正确的语法和格式来提高这个答案的质量吗?演示如何工作的现场演示也会非常有帮助。 – Zac

相关问题