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

Source: Internet
Author: User

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

And the white point is this: the top margin of the parent element's first child element margin-top if no valid border or padding are touched. It will continue to be a layer of a layer to find their superiors (parent element, ancestor Element). As long as the superior set a valid border or padding can effectively prevent it leapfrog.

WORKAROUND: Set Border-top or padding-top for the parent Div.

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

Related Article

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.