CSS Layout - position PropertyThe position attribute specifies the type of positioning method (static, relative, fixed, absolute, or sticky) to be applied to an element. The position property The position attribute specifies the type of positioning method to be applied to an element. There are five different position values:
Elements are actually positioned using the top, bottom, left, and right attributes. However, these properties have no effect unless the position property is set first. They work differently depending on the position value. CSS Layout - Floating and Clearing float property The float property can be set to one of the following values: left - the element floats to the left side of its container float: left|right; can automatically arrange and wrap lines, but requires clear to clear the float; display: inline-block can sometimes replace float to achieve the same effect. position: absolute|relative; To coordinate with top, left and other positioning; use: position: The difference between CSS layout float and positioning attributesCSS has three basic positioning mechanisms: normal flow, floating and absolute positioning. 1. Normal flow The position of the element box in the normal flow is determined by the position of the element in XHTML. Block-level elements are arranged from top to bottom, and the vertical distance between boxes is calculated by the vertical margin of the box. Inline elements are laid out horizontally in a row. Normal flow is the elements in the HTML document, such as block-level elements and inline elements, according to their display attributes in the document. Position:relative is the relative positioning of child block-level elements to the parent element. The positioning keywords use left/right/top/bottom. Sibling block elements are positioned relative to each other, but after the position is moved, the original position is still retained. And the subsequent positioning of sibling block elements is based on the position before being moved. float:right/left is the positioning of the sub-block-level element flow set towards the parent element, and the keywords used for positioning are margin/padding. The relative positioning between sibling block elements is re-rendered based on the new position after the move. They can overlap and the original position is cleared. The biggest difference between the two is position retention. People use this difference to create a sliding door menu using CSS code. 123WORDPRESS.COM Editor AddedGenerally, float is used for page layout, but you need to pay attention to clearing the float. Some special effects generally use position. Elements using position can appear anywhere on the page, which is convenient for some prompt boxes, special effects, etc. Specifically, you can click F12 on the page you see and study it slowly, and you will find a lot of fun. |
<<: Detailed explanation of how to dynamically set the browser title in Vue
>>: The difference between HTML name id and class_PowerNode Java Academy
Comments and messages were originally a great way...
Steps to configure whitelist access in mysql 1. L...
This article shares the installation and configur...
cause I once set up WordPress on Vultr, but for w...
1. Yum installation yum install subversion 2. Con...
Table of contents Add code to the Tree item; 1. S...
The application of containers is becoming more an...
Today we will look at why master-slave delay occu...
Underlining in HTML used to be a matter of enclos...
Table of contents Mixin Mixin Note (duplicate nam...
Table of contents question analyze solve Replace ...
Table of contents el-scrollbar scroll bar el-uplo...
React multiple ways to get the value of the input...
Table of contents Ideas Host Configuration Modify...
Table of contents 1.kvm deployment 1.1 kvm instal...