When using Div+CSS for website layout, you must consider the positioning issues in CSS when doing some special effects such as floating layers. This requires using the Positoin attribute and so on. Friends who are interested in css positioning, let’s take a look!
Positoin attribute has four values: static, fixed, absolute and relative. The latter two are often used in positioning in layout. As the name suggests, absolute refers to absolute positioning, that is, removing the object from the document flow. Drag out, use left, right, top, bottom and other properties for absolute positioning, while its cascade is defined by the z-index property. The object now has no margins, but still has padding and borders. Ralative refers to relative positioning, which is to offset the position in the normal document flow based on left, right, top, bottom and other attributes.
But what is the absolute law and what is the relative law? I have never studied it carefully before, and sometimes I am a little confused when it comes to specific applications. I believe many friends will also have this problem. I tested it specifically today and came to the following conclusions:
1. When the Positoin attribute value is Relative
The object’s original position is retained, and the objects behind it are retained as originally occupied. The document flow still maintains the original position
The value of Top represents the downward offset distance of the object relative to the original position
The value of bottom represents the upward offset distance of the object relative to the original position
When both exist at the same time, only Top works.
The value of left represents the distance to the right of the object relative to the original position.
The value of right represents the distance to the left of the object relative to the original position.
When both exist at the same time, only left takes effect. .
2. When the Positoin attribute value is absolute
The object is extracted from the document stream, and the original position is replaced by the subsequent object.
The value of Top represents the object The distance between the upper border and the top of the browser window
The value of bottom represents the distance between the object's lower border and the bottom of the browser window
When both exist at the same time, only Top takes effect; if both are not specified, the top The position will be consistent with the original document flow, that is, the vertical position will remain unchanged.
The value of left represents the distance between the left border of the object and the left side of the browser window
The value of right represents the distance between the right border of the object and the right side of the browser window
When both exist at the same time, only left takes effect ; If neither is specified, its left side will be consistent with the original document flow position, that is, the horizontal position will remain unchanged.
When the Positoin attribute value is absolute, if there is a first-level parent object (whether it is a parent object or a grandparent object, or any higher level, all are treated equally, ^_^) the Positoin attribute value is Relative, then The above relative browser window positioning will become relative parent object positioning, which is very helpful for precise positioning.
For more information about CSS, please refer to the manual: http://www.php.cn/xiazai/shouce/22
The conclusion reached after a long day of hard work ,hope its good for U.S. If there are any oversights, please correct me.
Related recommendations:
CSS positioning position and application scenario example analysis
##10 course recommendations on CSS positioning
##Introduction to examples of positioning background images using CSSThe above is the detailed content of Some research on Positoin, absolute, and Relative in CSS positioning. For more information, please follow other related articles on the PHP Chinese website!

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.

Article discusses CSS Flexbox, a layout method for efficient alignment and distribution of space in responsive designs. It explains Flexbox usage, compares it with CSS Grid, and details browser support.

The article discusses techniques for creating responsive websites using CSS, including viewport meta tags, flexible grids, fluid media, media queries, and relative units. It also covers using CSS Grid and Flexbox together and recommends CSS framework

The article discusses the CSS box-sizing property, which controls how element dimensions are calculated. It explains values like content-box, border-box, and padding-box, and their impact on layout design and form alignment.

Article discusses creating animations using CSS, key properties, and combining with JavaScript. Main issue is browser compatibility.

Article discusses using CSS for 3D transformations, key properties, browser compatibility, and performance considerations for web projects.(Character count: 159)

The article discusses using CSS gradients (linear, radial, repeating) to enhance website visuals, adding depth, focus, and modern aesthetics.

Article discusses pseudo-elements in CSS, their use in enhancing HTML styling, and differences from pseudo-classes. Provides practical examples.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools
