Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the margin property in html

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to use the margin attribute in html". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Margin is an abbreviation for all css margin attributes used by css in a declaration, and because margin controls the distance between block-level elements in css, the two are not visible.

One: how to use the css margin attribute

The margin property contains a number of properties, as follows:

Margin left: indicates that the distance is set to the left inside margin

Margin top: indicates the distance to set the block shape of the element at the top of the head

Margin right: indicates the setting distance from the right element block

Margin bottom: is to set the bottom block distance

II: css margin attribute usage tutorial

1.margin left usage:

The margin left:50px; syntax is followed by a number or percentage, which represents a distance of 50 pixels from the left element block, or 50% from the element.

To observe the example, we use two boxes:

Margin-left instance www.divcss5.com.php-a,.php-b {float:left; width:150px; height:120px; border:1px solid # F00}. Php-b {margin-left:50px}. Php-c {margin-left:50px}

We can change the value and observe the changes, but the effect is the size of the space on the left side of the element.

The use of 2.margin right is just the opposite of margin left, which is defined as how many pixels the element on the right is apart from.

3.margin top:50px, the syntax followed by a number, means that the upper margin is 50 pixels apart, and it can also be expressed as a percentage.

The usage of 4.margin bottom is similar to that of margin top, and is in the opposite direction.

This is the end of the content of "how to use the margin attribute in html". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report