4

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

JSFIdle

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 中它工作正常。

4

1 回答 1

9

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

  1. 家长 -text-align: center
  2. button child - 使用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>

于 2015-06-22T12:48:39.297 回答