Pratik N Pratik N - 7 months ago 8
Javascript Question

How to centre the content within a div without using margin property

I have a container within which i will get contents dynamically. i want all coming contents/div to be centred automatically.
i dont want to use margin property.

<div class="linContainer">

<div class="content1"></div>
<div class="content2"></div>

</div>

Answer

To center vertically AND horizontally, you can change the default display from block to table-cell.

Fiddle