Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button not center align in Safari

Button not centered align in Safari browser only.

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;
}

Above problem just come in Safari. In Chrome and Firefox it works fine.

like image 618
Junaid Avatar asked Jan 08 '23 02:01

Junaid


1 Answers

if you don't set a width for btn:

  1. parent - text-align: center
  2. button child - use display:inline-block instead of display: block

.wrap {
    text-align: center;
}
.center-block {
    display: inline-block;
}
<div class="wrap">
    <input value="Button" class="center-block" type="submit" />
</div>
like image 186
Dmitriy Avatar answered Jan 30 '23 09:01

Dmitriy