css - Text Align Center in Chrome (webkit) -
any idea why text-align: center doesn't center text within table cells? text-align: -webkit-center does?
the reason why display: table-cell applied have vertical-align work. removing not solution , doesn't answer question.
.wrapper { text-align: center; } .column { width: 33%; display: inline-block; text-align: center; /*text-align: -webkit-center;*/ border: 1px solid gray; float: left; } span { display: table-cell; text-align: center; vertical-align: middle; width: 50px; height: 50px; background-color: gray; border-radius: 25px; } span:before { content: "text" } <div class="wrapper"> <div class="column"> <span></span> </div> <div class="column"> <span></span> </div> <div class="column"> <span></span> </div> </div>
the issue isn't display: table-cell nature of span element.
please note text-align property in css used aligning inner content of block-level elements.
the html span tag inline-level element. hence, doesn't apply default inline-level elements , therefore have use browser-specific css i.e. text-align: -webkit-center.
sources:
css tricks almanac - https://css-tricks.com/almanac/properties/t/text-align/
w3schools - http://www.w3schools.com/html/html_blocks.asp
Comments
Post a Comment