【问题标题】:Button not center align in SafariSafari中的按钮不居中对齐
【发布时间】:2015-09-07 18:35:07
【问题描述】:

仅在 Safari 浏览器中按钮不居中对齐。

JSFIddle

HTML

<div class="" style=" width: 100%; ">
    <input value="Button" class="center-block" type="submit" style=""/>
</div>

CSS

.center-block {
display: block;
margin-right: auto;
margin-left: auto;
}

上述问题只是在 Safari 中出现。在 Chrome 和 Firefox 中运行良好。

【问题讨论】:

    标签: html css safari center-align


    【解决方案1】:

    如果你没有为 btn 设置宽度:

    1. 父级 - text-align: center
    2. 按钮子 - 使用 display:inline-block 而不是 display: block

    .wrap {
        text-align: center;
    }
    .center-block {
        display: inline-block;
    }
    <div class="wrap">
        <input value="Button" class="center-block" type="submit" />
    </div>

    【讨论】:

    猜你喜欢
    • 2012-02-11
    • 1970-01-01
    • 2013-08-05
    • 2017-03-17
    • 2017-06-03
    • 1970-01-01
    • 2012-09-14
    • 2016-05-11
    • 2023-02-09
    相关资源
    最近更新 更多