Reputation: 137
I am trying to center the text span in the following table-cell, table-row
<div style="display: table; margin-left: auto; margin-right: auto;">
<div style="display: table-cell; width:400px;">
<div style="display: table-row; text-align: center;">
<span>
Test
</span>
</div>
</div>
</div>
jsfiddle ( http://jsfiddle.net/7p3zgne0/ )
Upvotes: 0
Views: 507
Reputation: 15667
table-cell
and table-row
are inverted.
<div style="display: table; margin-left: auto; margin-right: auto;">
<div style="display: table-row; width:400px;">
<div style="display: table-cell; text-align: center;">
<span>
Test
</span>
</div>
</div>
</div>
Upvotes: 3
Reputation: 2296
It should probably be like this:
<div style="display: table; margin-left: auto; margin-right: auto;">
<div style="display: table-row; width:400px;">
<div style="display: table-cell; text-align: center;">
<span>
Test
</span>
</div>
</div>
</div>
Note how the table-cell
is inside the table-row
. In your code, you have them the other way around.
Upvotes: 2
Reputation: 1556
<div align="center">
center aligned content (like a span)
</div>
Apply this to your deepest div node
Upvotes: 0