2013-08-21 24 views
0

我正在致力於通訊HTML,並且我無法給中心對齊div。如何將按鈕對齊到div的中心。以下是簡單代碼如何在不使用保證金的情況下在div中對齊錨點

<table border="0" cellpadding="0" cellspacing="0" width="600"> 
<tr> 
<td> 

<div style="text-align:center;"> 
<a href="#" style="display:block; width:150px; text-decoration:none; font-weight:bold; color:#fff; background:#c72622; font-size:20px; border-radius:7px; -webkit-border-radius:7px; padding-top:10px; padding-bottom:10px;"> 
Buy Now 
</a> 
</div> 

</td> 
</tr> 
</table> 
+0

是有人幫助我:S ???它已經2小時沒有響應了:( –

回答

0

align="center"添加到您的包含表格單元格中。這是在HTML電子郵件中居中對齊的最佳方式。

0

避開所有填充和邊距,它們在許多客戶端中很差/錯誤地得到支持。改爲使用大量嵌套表格並改爲使用<tr><td height="1234" align="center/left/right">。儘可能避免<table align="center/left/right">屬性,因爲outlook會產生額外的空白。我爲我的包裝表使用<table align="center">

對於垂直對齊,請使用<td> s和<tr> s的valign屬性。如果該行中的另一個td的圖像具有要垂直對齊的高度,則效果最佳。

+1

你應該在你的包裝表'​​'上使用'align ='center'''''''''''''''''''''''''''''''''當在'​​'上使用時。 – John

相關問題