Emulate display:table for replaced elements in WebKit & Firefox
Webkit and Firefox do not respect display: table* properties when assigned to replaced elements, e.g. buttons. But we can emulate this by switching over to flex box just for those two.
by Schepp
HTML
<div class="table">
<div class="col">
bla
</div>
<div class="col">
bla
</div>
<div class="col">
bla
</div>
<div class="col">
bla
</div>
</div>
<div class="table">
<button class="col" onclick="alert()">
bla
</button>
<button class="col" onclick="alert()">
bla
</button>
<button class="col" onclick="alert()">
bla
</button>
<button class="col" onclick="alert()">
bla
</button>
</div>
CSS
.table{
display: table;
width: 100%;
border:1px solid red;
}
.col{
display: table-cell;
padding: 0 auto !important;
border:1px solid green;
text-align: center;
}
/* Switching to Flexbox for Webkit and Mozilla */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.table{
display: -webkit-box;
}
.col{
display: block;
margin: 0;
-webkit-box-flex: 1;
}
}
@media screen and (min--moz-device-pixel-ratio:0) {
.table{
display: -moz-box;
}
.col{
display: block;
margin: 0;
-moz-box-flex: 1;
}
}