user1995781 user1995781 - 1 month ago 15
CSS Question

DIV table-cell width 100%

Here is my code:

<div style='display: table'>
<div style='height:200px; width:100%; text-align: center; display: table-cell; vertical-align: middle'>No result found</div>
</div>


Why is that the
width:100%
is not working? How can I solve it?

Answer

Try giving width: 100% to parent so that the child has full width.

<div style='display: table; width:100%; background:#f00;'>
    <div style='height:200px; width:100%; text-align: center; display: table-cell; vertical-align: middle'>No result found</div>
</div>