How to set the margin property of CSS

Source: Internet
Author: User
How to set the margin property of CSS? Margin is an outer margin. This time to teach you how to use the margin property to manipulate the Div. How to manipulate the spacing between div and div

Margin is used to set the distance between object labels, such as 2 upper and lower div boxes, and we can use the margin style to achieve up to 2 box spacing. Margin rendering is located on the outside of the object border, close to the border, marign and padding position, but the CSS padding is close to the border on the inside of the border.

The DIV CSS margin refers to the CSS property word margin,margin is the epitaxial margin that sets the object's edges, with no background color or color.

1. Margin syntax

margin:10px

The value of margin is a digital +html unit and can also be auto (auto, adaptive)

2. Application Structure

div{margin:10px}

Set the Div object to a distance of 10px

3. Margin description

Margin is the distance of the outer margin of the Set object.

The value of margin has three cases, which can be positive integers and negative integers plus units such as px pixels (margin-left:20px), auto attributes (Margin-left:auto Auto), and a percentage (%) value (margin-left:3%).

Margin extension (single-sided spacing attribute word)

Margin-left the left epitaxial margin of the object (margin-left:5px; Left epitaxial distance 5px)

Margin-right object to the right of the epitaxial margin (margin-right:5px; Right epitaxial distance 5px)

Margin-top the upper epitaxial margin of the object (margin-top:5px; Upper extension distance 5px)

Margin-bottom the bottom epitaxial margin of the object (margin-bottom:5px; 5px below epitaxial distance)

Related reading:

What are the different ways to set the background color of a div


Div+css How to use


what is CSS

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.