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 css uses the one-sided margin attribute to set the value for the outer margin on one side of an element

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how css uses the one-sided margin attribute to set the value for the outer margin on one side of an element. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The one-sided outer margin attribute can be used to set the equipment setting value for the outer margin on the single side of the element. If you want to configure the left margin of the p element to 20px. Instead of applying margin (you need to type a lot of auto), you can use the following methods:

P {margin-left: 20px;}

You can apply any of the following properties to set only the corresponding margin, without directly affecting all other margins:

Margin-top

Margin-right

Margin-bottom

Margin-left

Multiple such unilateral attributes can be used in a rule, such as:

H3 {margin-top: 20px; margin-right: 30px; margin-bottom: 30px; margin-left: 20px;}

Admittedly, it is generally easier to use margin to deal with this situation:

P {margin: 20px 30px 30px 20px;}

Whether you use unilateral attributes or apply margin, the results are all different. In general, it is easier to use margin if you want to set the outsides of the equipment for multiple edges. However, from the point of view of document representation, it is not necessary to use either way in theory, so you should decide on a way that is easier for me.

Thank you for reading! This is the end of the article on "how css uses the one-sided margin attribute to set the outer distance on one side of the element". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see it!

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

Development

Wechat

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

12
Report