Jump to content

Div Element Moved


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 post
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 post
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 post
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 post
Share on other sites
			   +-----------------------------------+			   |				 contents contents |			   |				 contents contents |<-- margin --> | <-- padding --> +---------------+ |			   |				 | child child   | |			   |				 +---------------+ |			   +-----------------------------------+

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...