Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the four common attribute values of position in css

Shulou Source: shulou.com Published: 2022-06-03 16:31:38 09月17日 Update

Editor to share with you what are the four common attribute values of position in css. I believe most people don't know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.

1. Default location of static.

In general, we don't need to declare it specifically, but sometimes when we encounter inheritance, we don't want to see the attributes inherited by the element affect itself, so we can use Position:static to cancel inheritance, that is, to restore the default value of element positioning. The element set to static is always in the position given by the page flow (the static element ignores any top, bottom, left, or right declarations). It's not usually used.

2. Relative relative positioning. Relative positioning is relative to the default position of the element.

The value of the top,right,bottom,left it offsets is based on its original location, regardless of what happens to other elements. Notice that the position of the element moved by relative still occupies space.

3. Absolute absolute positioning.

Set to the absolute element, and offset based on the parent container if its parent container is set to the position attribute and the position property value is absolute or relative. If the parent container does not set the position property, the offset is based on body. Note that the element that sets the absolute attribute does not occupy a place in the standard stream.

4. Fixed fixed positioning.

The location is set to the fixed element and can be positioned to the specified coordinates compared to the browser window. Regardless of whether the window is scrolled or not, the element remains in that position. It is always based on body. Note that the element that sets the fixed attribute does not occupy a place in the standard flow.

These are all the contents of the article "what are the four common attribute values of position in css?" 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: Elements locations attributes positioning containers articles offsets common content standards generally speaking not much coordinates basics most commonly used more browsers knowledge space Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Microsoft Redmi Xiaomi