Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the css one-sided margin attribute

Shulou Source: shulou.com Published: 2022-06-01 10:47:42 10月03日 Update

This article mainly shows you the "css single margin attribute how to use", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "css single margin attribute how to use" this article.

You can use the single-sided margin attribute to configure values for the outer margin on one side of the element. Suppose you want to configure the left margin of the p element to 20px. Instead of using margin (you need to type a lot of auto), you can do the following:

P {margin-left: 20px;}

You can apply any of the following properties to configure only the outer margins on the response without directly affecting all other outer margins:

Margin-top

Margin-right

Margin-bottom

Margin-left

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

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

Admittedly, it is easier to use the margin outline for this situation:

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

Whether you use unilateral attributes or use margin, you will get the same result in the end. In general, it is easier to use margin if you want to configure outer margins for multiple edges. However, from the point of view of the emergence of documents, it is not necessary to use either way in practice, so we should decide on a simpler path for me.

Implication and confession

Hint: the default margin (margin) value for body tags signed by Netscape and IE is 8px. And Opera is not so much. Similarly, Opera defines the default value of padding as 8px, so if you are eager to adjust a small piece of the edge of the entire site and roughly display it in Opera, then you must define the padding development of body.

The above is all the content of this article entitled "how to use the css single margin attribute". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Attributes configuration content articles elements multiple ways learning help rough confession anomaly documentation easy to understand more organization outline status knowledge eventually Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple MariaDB MySQL Huawei