Home >Web Front-end >HTML Tutorial >div css absolute positioning and relative positioning_html/css_WEB-ITnose
div css absolute positioning and relative positioning
Many friends have asked me how to distinguish absolute from relative and how to use them ? We all know that absolute is absolute positioning and relative is relative positioning, but what do absolute and relative mean? What is the absolute, and relative is relative to what? So what characteristics do they have and what effects can they produce? What kind of skills are there between the two? Let’s explain them one by one below. Absolute, the writing method in CSS is: position:absolute; It means absolute positioning. It refers to the upper left corner of the browser and cooperates with TOP, RIGHT, BOTTOM, and LEFT (hereinafter referred to as TRBL) for positioning. When TRBL is not set, the default is based on the parent's original point for marking. If TRBL is set and the parent does not set the position attribute, then the current absolute will be positioned with the upper left corner of the browser as the original point, and the position will be determined by TRBL. Generally speaking, it is easy to make mistakes when using Absolute if the webpage is centered, because the webpage always automatically adapts to the size of the resolution, and Absolute will use the upper left corner of the browser as the The original point will not change position due to changes in resolution. This is where many people go wrong. The characteristics of the webpage on the left are very similar to Relative, but there are still essential differences. Relative, the writing method in CSS is: position:relative; It means relative positioning. It refers to the original point of the parent as the original point. If there is no parent, the previous element will be in the order of the text flow. The bottom is the original point, which is positioned with TRBL. When there are CSS attributes 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 higher it is at the top. The value range is a natural number. However, z-index is not omnipotent. Z-index is also subject to level restrictions. For information about this level restriction, please see "Unbreakable Levels" |