CSS如何在div中将链接元素居中 [英] CSS How to center link elements within a div
本文介绍了CSS如何在div中将链接元素居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有一个div,其中将包含3个按钮,并且我希望这些按钮位于div的中心.
So I have a div which will contain 3 buttons and I want these buttons centered within the div.
到目前为止,我已经尝试过
I tried this so far
.centerButtons
{
margin-left: auto;
margin-right: auto;
width: 90%;
}
哪个div包含按钮居中居中,这很好,但是该div中的实际按钮未居中.这是我到目前为止的标记.
Which centers the div containing the buttons which is fine, but the actual buttons within this div are not centered..This is my mark up so far..
<div class="clearfixLeft clearfix centerButtons">
<xsl:if test="sc:fld('Link One', .)!=''">
<div class="fl_left mr_7 mt_10">
<div class="green-btn-solid">
<sc:link field="Link One">
<span class="btnspan">
<sc:text select="." field="Link One Text" />
</span>
</sc:link>
</div>
</div>
</xsl:if>
...
</div>
其他类
/* link styles */
.green-btn-solid {line-height: 21px; height: 21px; background: url(../../images/SOURCE/btn_grn_r.gif) 100% 0 no-repeat; width: auto; display: block; padding-right: 30px; }
.green-btn-solid span {display: block; float: left; background: url(../../images/SOURCE/btn_grn_l.gif) 0 0 no-repeat; line-height: 21px; height: 21px; padding-left: 12px; color: #fff;}
推荐答案
您是否尝试过text-align:center ;?我很确定它也适用于元素.
Have you tried text-align: center;? I'm pretty sure it works on elements as well.
这篇关于CSS如何在div中将链接元素居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文