2017-08-07 30 views
-2

我想中心下面的按鈕 - 我試圖從其他例子改變CSS代碼或使用文本對齊:中心但都沒有任何選項已經工作。我知道代碼本身可以修復,但我是一個新手,所以任何提示都會有所幫助。與HTML/CSS的中心按鈕

感謝

<a class="btn-group" 
style="color: #ffffff;" 
href="http://requestgoods.com/item-request/">Request Goods Now</a></button> 
+0

居中按鈕如何?在一個div?在頁面上?你需要解釋更多 –

+0

對不起 - 我想中心按鈕在頁面上,再次道歉 –

+0

把這個問題。也許提供一個小提琴。 – Red

回答

0

試試這個:

div { 
 
    text-align: center; 
 
}
<div> 
 
    <button><a class="btn-group" style="color: #000" href="http://requestgoods.com/item-request/">Request Goods Now</a></button> 
 
</div>

0

取一個外層div並設置text-align : center到這個div。

使用此代碼:

<div style = "text-align: center;"> 
 
    <button> 
 
    <a class="btn-group" href="http://requestgoods.com/item-request/">Request Goods Now</a> 
 
    </button> 
 
</div>

+0

我的代碼和你的代碼有什麼不同?你只能將我的代碼轉換爲內聯樣式。 – Ehsan

+0

我添加了一個div,並將所有內容放在該div中... –

+0

您嘗試過text-align:center on button its not working ...如果您將div設置爲中心,那麼它會轉到該div的中心。 –

0

最簡單的解決方法是:

HTML

<div> 
<button> 
<a class="btn-group" 
style="color: #ffffff;" 
href="http://requestgoods.com/item-request/">Request Goods Now</a> 
</button> 
</div> 

CSS

div { 
    text-align:center; 
}