Jump to content

Div Element Moved


homer.j.simpson
 Share

Recommended Posts

Padding does work. I'm just curious why margin setting doesn't act like it supposed to be. I mean it suppose to adjust the distance from the one edge of parent element to child one; not the distance between same level elements. Now, it's like a padding and move the parent element to set distance.

Edited by endrew
Link to comment
Share on other sites

Padding does work. I'm just curious why margin setting doesn't act like it supposed to be. I mean it suppose to adjust the distance from the one edge of parent element to child one; not the distance between same level elements. Now, it's like a padding and move the parent element to set distance.
Actually, it is supposed to move the same level elements. Padding is what is used to move child elements and text. Here's a link that explains the box model that CSS uses to lay out a page:http://w3schools.com/css/css_boxmodel.asp
Link to comment
Share on other sites

Margin is supposed to determine the distance of a box from the edges of its container. Margin always affects the position of the box.
Ya that's what I meant. Instead of moving just the child elements, it moves the whole container. Anyway, I found the root cause; it was height attributes that I set on both the parent and the child. When I eliminate the height attribute of the chlid, the margin works as it should.
Link to comment
Share on other sites

Margin is supposed to determine the distance of a box from the edges of its container. Margin always affects the position of the box.
But it also defines the distance between the box and other elements around it not just it's parent container. Besides I thought padding is supposed to define the distance between the edges of a parent and its children.
Link to comment
Share on other sites

			   +-----------------------------------+			   |				 contents contents |			   |				 contents contents |<-- margin --> | <-- padding --> +---------------+ |			   |				 | child child   | |			   |				 +---------------+ |			   +-----------------------------------+

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...