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?

see jsfiddle here

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

demo


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -