2017-08-07 28 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; 
}