如何对齐按钮

时间:2014-04-25 08:16:13

标签: html

请问您如何在中心对齐此按钮?

<script type="text/javascript" src="https://office.instantticketing.com/pit/scripts/pit-widget-boot.js"></script>
<button onclick="javascript:pitWidgetBootToken('khaxfcarjhtso4h9lubk5ywwcp21386707097031');">
    <span style="text-align: center; line-height: 1.0; font-size: 16px; text-transform: none;">Book now</span>
</button>

2 个答案:

答案 0 :(得分:0)

最好的方法是使用css;例如:

.button_centre {
    margin:auto;
    display:block;
}

和html / js /

<button onclick="javascript:pitWidgetBootToken('khaxfcarjhtso4h9lubk5ywwcp21386707097031');" class="button_centre">
    <span style="text-align: center; line-height: 1.0; font-size: 16px; text-transform: none;">
        Book now
    </span>
</button>

查看Fiddle of this question

答案 1 :(得分:0)

在div中包裹按钮并在div上设置text-align:center

http://jsfiddle.net/ykZgJ/

<div style="text-align:center">
<button onclick="javascript:pitWidgetBootToken('khaxfcarjhtso4h9lubk5ywwcp21386707097031');"><span     style="text-align: center; line-height: 1.0; font-size: 16px; text-transform: none;">Book now</span></button>
</div>