2014-02-09 34 views
0

我有我的網站下面的代碼,我想在網頁居中圖像如何中心的鏈接一組圖片

<ul class=""> 
     <a href="https://www.github.com"> 
      <img style="height:auto; width:auto; max-width:50px; max-height:50px;" src="images/github.png" border="0" alt="Code" class=""> 
     </a> 
     <a href="http://www.linkedin.com"> 
      <img style="height:auto; width:auto; max-width:50px; max-height:50px;" src="images/linkedin.png" border="0" alt="Connect" class=""> 
     </a> 
     <a href="https://www.twitter.com"> 
      <img style="height:auto; width:auto; max-width:50px; max-height:50px;" src="images/twitter.png" border="0" alt="Twitter"> 
     </a> 
     </ul> 

我也有下面的CSS:

a{ 
    color:black; 
    text-decoration: none; 
    margin: 0px auto; 
    width: 400px; 
} 
ul{ 
    padding: 0; 
} 

我需要做什麼才能將我的網站上的所有三個圖像鏈接居中?

回答

0

使用

<ul style="display:block;margin:0px auto;"> 
    ///tags 
</ul> 

它將證明UL標籤。

<ul style="width:100%;display:block;text-align:center;"> 
    ///tags 
</ul> 

它將證明UL標籤

0

使用此代碼的內容:

DEMO

ul{ 
    padding: 0; 
    text-align:center; /* added */ 
} 
+0

謝謝!這工作。另一個快速問題,我將如何添加一些垂直填充圖像? – user2604504

+0

@ user2604504使用'padding:10px 0;'爲圖像 –

0
ul{ 
    margin: 0 auto; /* For hate it at the center*/ 
    padding: 0; 
    width: aWidthToTheDiv; /* You could set it to 100% or an value as 800px (example) */ 
} 

而做:)

這應該工作,也是喲你可以添加一個標籤爲「text-align:center;」但是這會讓所有的文字保持在中心位置,並且可能您希望將其放在其他路線中。

0

既然你還沒有使用<li>標籤與<ul>

沿着我建議你使用<p>標籤。

這可能很有趣。但它很簡單,你不需要做任何額外的造型。

所有你需要做的就是添加text-align:center

試試這個 - >WORKING DEMO