2017-04-10 106 views
-13

這是頁面。我在頁面下方有按鈕。我想對齊中心的按鈕..任何一個幫我在頁面中水平對齊按鈕

        -centerbutton-- 
+4

你能給我們一些代碼嗎?我們無法真正幫助你。 – Xogno

+0

@Xogno真的如此:P –

回答

2

,您可以給按鈕下面的CSS代碼:

.container{ 
display: flex; 
} 

您:

button{ 
margin: 0 auto; 
} 

您還可以在按鈕的容器上使用Flexbox的然後可以使用以下內容:

button{ 
margin: auto; 
} 
+0

謝謝!顯示器:flex爲我工作。 – Dani

+3

快速注意:每個瀏覽器都不支持flexbox: http://caniuse.com/#search=flexbox – gwesseling

-2

在這裏,你走,基本之一。您沒有提供代碼,因此我們無法使用您的代碼提供答案。

body { 
 
    text-align: center 
 
}
<button>center</button>

+0

謝謝@tesseract – Prashee

+0

接受答案和投票,如果它幫助你 – Swellar

+0

@Downvoter關心解釋? – Swellar