如何居中对齐div

问题描述:

我从Mail chimp获得了一些嵌入代码,以在我的网站上显示新闻快递注册框。我想中心对齐时事通讯框,但不知道什么div我需要添加样式。我尝试使用style =“text-align:center”,但它没有奏效。我认为可能会有一种过度的骑行风格?如何居中对齐div

www.skinmade.com.au(见页面底部)

在此先感谢。

给您的容器div固定的宽度,设置显示器这样的“块”,并设置左,右边距为“自动”:

#mc_embed_signup { 
    display: block; 
    margin: 0 auto; 
    width:300px; 
} 

您也可以与您解决这个问题提交按钮不显示全文如下:

#mc_embed_signup input.button { 
    width: auto; 
} 

试试这个在你的CSS:

#mc_embed_signup input.button { 
display: block; 
width: 133px; 
text-align: center; 
position: relative; 
height: 43px; 
/*margin:0;*/ 
} 

试试这个

input.button{ display: inline-block; } 

#mc_embed_signup{ text-align:center; } 

#mc_embed_signup{ width:200px; margin: auto auto; } 
+0

确定这工作,虽然不能与它上面的图标内联。也许它会像图标一样看起来更好。有关代码的任何建议? – user2593460 2014-10-01 04:19:15