InQusitive InQusitive - 1 year ago 53
CSS Question

Making display:inline-block moves the paragraph to left

Why does the div display property

move the paragraph to left which was centered by
margin:0 auto
without display property.

padding: 20px;
margin: 0 auto;
display: inline-block;
width: 900px;
height: 2000px;

is the class id of the div which has some paragraph inside it.
When I add
display: inline-block
the paragraph is moving to the left side. Why is it so?

Answer Source

When you change the display property of a DIV from display:block to display:inline-block. It becomes like a normal inline element, with few extra perks.

You can use a definitive margins like margin-left:100px; and that will work. But when you say auto.

The default automatic behavior for inline-block is margin:0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download