(ix) Learn the margin properties of CSS

Source: Internet
Author: User

Reference:

The margin property is supported by all browsers.

Note: The property value "Inherit" is not supported by any version of Internet Explorer (including IE8).

Definition and usage

The margin shorthand property sets all margin properties in a declaration. This property can have between 1 and 4 values.

Description

This shorthand property sets the width of all margins for an element, or sets the width of the margins on each edge.

The vertical adjacent margins of block-level elements are merged, while the inline elements do not actually occupy the upper and lower margins. The left and right margins of the inline elements are not merged. Similarly, the margins of floating elements are not merged. Allows you to specify a negative margin value, but use caution.

Note: Negative values are allowed.

Example 1
margin:10px 5px 15px 20px;

    • Top margin is 10px
    • Right margin is 5px
    • Lower margin is 15px
    • The left margin is 20px
Example 2
margin:10px 5px 15px;

    • Top margin is 10px
    • Right margin and left margin are 5px
    • Lower margin is 15px
Example 3
margin:10px 5px;

    • Top margin and bottom margin are 10px
    • Right margin and left margin are 5px
Example 4
margin:10px;

    • All 4 margins are 10px
value     Description The Auto      browser calculates the margin. Length    Specifies the value of the margin in a specific unit, such as pixels, centimeters, and so on. The default value is 0px. %     Specifies the margin based on the percentage of the parent element's width. Inherit   specifies that margins should be inherited from the parent element. 

Default value: 0

(ix) Learn the margin properties of CSS

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.