html - Centering a display:table div -
i have full width wrapper div. inside it, there's div set display: table.
i've set wrapper text-align: center, table div not getting centered. why that? missing here in order center display: table div horizontally inside wrapper?
<div class="wrapper"> <div class="tb"> <div class="tb-cell">1</div> <div class="tb-cell">2</div> <div class="tb-cell">3</div> </div> </div> css:
.wrapper { width: 100%; background: #e0e0e0; text-align: center; } .tb { display: table; width: 100px; background: silver; } .tb-cell { display: table-cell; }
the problem that
the
text-aligncss property describes how inline content text aligned in parent block element.
then, can't center element display: table, because isn't inline content.
but can use inline-table instead:
.tb { display: inline-table; }
Comments
Post a Comment