


In-depth understanding of CSS positioning, complete mastery of CSS positioning, relative positioning and absolute positioning_html/css_WEB-ITnose
In fact, the previous standard flow and floating flow are very understandable, but positioning is not easy to understand, especially relative positioning and absolute positioning. Many students who are just starting to learn cannot distinguish between them. So here, Teacher Xiaoqiang shares with you the learning of CSS positioning.
Through our previous studies, our web page layout method:
1. Standard flow (the most stable)
2. Floating flow (float second)
3. Positioning flow (last in stability)
Positioning is a layout method that is completely separated from the standard flow.
In fact, the previous standard flow and floating flow are very understandable, but positioning is not easy to understand, especially relative positioning and absolute positioning. Many students who are just starting to learn cannot distinguish between them. So here, Teacher Xiaoqiang shares with you the learning of CSS positioning.
We know that positioning is used together with directional nouns. To adjust the position, most of them use top, left, bottom, and right.
First, let’s look at the classification of positioning:
1. Absolute positioning absolute
position: absolute;
Used for absolute positioning and relative positioning Relatively speaking, there are more places. What are the characteristics of absolute positioning? Here, Teacher Xiaoqiang will summarize it for everyone.
1. If the positioning does not have a parent box
then this box, after adding absolute positioning, will take the upper left corner of the browser as the origin, and all movements will also be based on that The origin is moved.
The case is as shown in the picture:
After preview
2. If there is a parent box, but the parent box, Without positioning, the result will not change, and the box will still take the upper left corner of the browser as its origin.
After preview
3. If there is a parent box and the parent box has positioning, then at this time, the absolute positioning will be based on the parent box The upper left corner is the origin and aligned.
As shown in the picture:
Generating effect:
4. Absolute positioning has a very important feature, It does not occupy any position and is completely separated from the standard flow, so it will rise and the standard flow will occupy its rear side.
2. Relative positioning (relative)
position:relative
Relative positioning is simple. Regardless of whether there is a parent box or not, it takes its upper left corner as the origin.
Also, it occupies a position, that is, there are other boxes that will be placed below it.
3. Fixed positioning
position: fixed
Fixed positioning is also relative to the browser, it is fixed at a certain position in the browser. (IE6 does not support fixed positioning and can only be solved separately)
Fixed positioning does not occupy a position and is completely out of the standard flow.
4. Static positioning
position:static
It is almost the same as the standard flow, there is no special positioning, and it occupies position.
5. Stacking order:
z-index: numerical value;
The larger the value, the higher the box. Note: You must not add units after the value.
.one{z-index:10;}
Summary:
In terms of positioning, there are static positioning and relative positioning that occupy position, and absolute positioning that does not occupy position. Positioning and fixed fixed positioning. This is very important and has a great impact on our layout of standard flow.
The mantra we must remember is that children are absolute and parents are relative. This is the most suitable layout concept for our layout.

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
