2016-09-17 48 views
1

我想集中一個按鈕或一個標籤內的行(它自己)。如何集中一個按鈕div

我已經寫了這個CSS,使它變成黃色,在它周圍放置一個邊框等,但它總是左對齊。我如何集中它?

a.butt, button.butt { 
    border: 1px solid #ffff01; 
    background-color: transparent; 
    height:50px; 
    cursor:pointer; 
    padding-left: 40px; 
    padding-right: 40px; 
    padding-top: 10px; 
    padding-bottom: 10px; 
    text-decoration: none; 
    text-align: center; 
    color: #ffff01; 
} 

感謝您的幫助

回答

1

幾種方法可以做到這一點,但也許

a.butt, button.butt { 
border: 1px solid #ffff01; 
background-color: transparent; 
height:50px; 
cursor:pointer; 
padding-left: 40px; 
padding-right: 40px; 
padding-top: 10px; 
padding-bottom: 10px; 
text-decoration: none; 
text-align: center; 
color: #ffff01; 

display: block; 
margin-left: auto; 
margin-right: auto; 
width: ??px; 
} 

會做的伎倆。

0
margin-left:auto; 
margin-right:auto; 
width:150px; //width as you want 
display:block; 
+0

<div>

例子,而這些代碼可以回答這個問題,提供了關於如何和/或爲什麼它解決了這個問題會提高更多的情況下做到這一點答案的長期價值。 – zurfyx

相關問題