html - Can't use display:table; together with text-align: center; -
i can't use "text-align: center;" "display: table;" accepts "display: table;" , when delete "display: table;" text gets centered want them both because "display: table;" keeps line @ bottom of text long text is.
this css:
h2 { margin-top: 70px; border-bottom: 2px black solid; text-align: center; display: table; } and html:
<h2><?php echo ucfirst($category[0]['name']); ?></h2>
display:table removes block behavior of element width defined content; can't see visual text centered because there no more space around center element if want table centered on page can use auto margins (center entire element), check snippet background see happen:
h2 { text-align: center; background: tomato; border-bottom: 2px black solid; } .table { display: table; margin: 70px auto 0; } <h2 class="table">my title</h2> <h2>my title</h2>
Comments
Post a Comment