The difference between the position attribute absolute and relative connection

Connection : https://www.cnblogs.com/duyanli/p/3534005.html

Every time you want to use the Position attribute, you always have to search for the difference between these two attribute values: copy the results on the Internet today, so that you can look at them later.

  

Absolute, written in CSS is: position:absolute; he means absolute positioning, he refers to the upper left corner of the browser, with TOP, RIGHT, BOTTOM, LEFT (hereinafter referred to as TRBL) for positioning, if TRBL is not set, By default, the original point is the original point based on the parent's marking. If TRBL is set and the parent does not set the position attribute, the current absolute is positioned with the upper left corner of the browser as the original point, and the position will be determined by TRBL.

Generally speaking, using Absolute is easy to make mistakes if the web page is centered, because the web page has always been automatically adapted to the size of the resolution, while Absolute will take the upper left corner of the browser as the original point, and will not be changed due to the change of resolution. Change location. A lot of people go wrong on this one. The characteristics of the left page of the web page are very similar to that of Relative, but there are still essential differences.

Relative, written in CSS is: position:relative; he means absolute relative positioning, he refers to the original point of the parent as the original point, without the parent, the original point of the BODY is used as the original point, with TRBL for positioning, When there are CSS properties such as padding in the parent, the original point of the current level is positioned with reference to the original point of the parent content area.

Sometimes we also need to rely on z-index to set the upper and lower relationship of the container. The larger the value, the more at the top, and the value range is a natural number. Of course, it should be noted that the parent-child relationship cannot be set up and down with z-index. The child must be on the top and the parent on the bottom.

Every time you want to use the Position attribute, you always have to search for the difference between these two attribute values: copy the results on the Internet today, so that you can look at them later.

  

Absolute, written in CSS is: position:absolute; he means absolute positioning, he refers to the upper left corner of the browser, with TOP, RIGHT, BOTTOM, LEFT (hereinafter referred to as TRBL) for positioning, if TRBL is not set, By default, the original point is the original point based on the parent's marking. If TRBL is set and the parent does not set the position attribute, the current absolute is positioned with the upper left corner of the browser as the original point, and the position will be determined by TRBL.

Generally speaking, using Absolute is easy to make mistakes if the web page is centered, because the web page has always been automatically adapted to the size of the resolution, while Absolute will take the upper left corner of the browser as the original point, and will not be changed due to the change of resolution. Change location. A lot of people go wrong on this one. The characteristics of the left page of the web page are very similar to that of Relative, but there are still essential differences.

Relative, written in CSS is: position:relative; he means absolute relative positioning, he refers to the original point of the parent as the original point, without the parent, the original point of the BODY is used as the original point, with TRBL for positioning, When there are CSS properties such as padding in the parent, the original point of the current level is positioned with reference to the original point of the parent content area.

Sometimes we also need to rely on z-index to set the upper and lower relationship of the container. The larger the value, the more at the top, and the value range is a natural number. Of course, it should be noted that the parent-child relationship cannot be set up and down with z-index. The child must be on the top and the parent on the bottom.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325523596&siteId=291194637
Recommended