Margin-top is not acting on the parent element

Source: Internet
Author: User
Why Margin-top is not acting on the parent element:
Recommendation : As far as possible handwriting code, can effectively improve the learning efficiency and depth.
As for the basic usage of the Margin-top attribute, it is simply to set the top margin of an object and see the following code example:


<! DOCTYPE html>

The above code can set the top margin of p to 50px, everything works well, without any problems, and then look at the next piece of code:


<! DOCTYPE html>

1. There is no border between the top margin of the parent element and the top margin of the child element.
2. 3. 3. The positioning properties (except static and relative), overflow (except for the visible) and display are not set in the parent and child elements: Inline-block and so on.
4. Either the parent element or the resource is not floating.
Note: The above conditions must be met before you can. The way to solve this situation is also simple, as long as it destroys one of the above situations.
More about the margin merge content can be found in the

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.