2017-04-11 128 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

相關問題