css-Sub Div set margin-top, the parent Div moves down with the child div

Source: Internet
Author: User

According to Graceie's blog

The reason this problem occurred is thataccording to the specification, if a box does not have a filler (padding-top) and a top border (border-top), then the top margin of the box overlaps with the top margin of the first child in its internal document flow.

Again the white point is: The top margin of the first child element of the parent element margin-top if a valid border or padding is not touched. The trouble of" leading "(parent element, ancestor Element) is constantly being found on a layer. As long as the leadership to set an effective border or padding can effectively control the goal of the non-leader of the margin to prevent it leapfrog, false preach Imperial decree, their own margin when the leader of the margin execution.

So the solution: set Border-top or Padding-top to the parent div.

http://www.hicss.net/do-not-tell-me-you-understand-margin/

css-Sub Div set margin-top, the parent Div moves down with the child div

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.