float:left/right/none; 1. Same level floating (1) Make block-level elements appear in the same line (all elements to be displayed in the same line must be floated) <div class="box1">box1</div> <div class="box2">box2</div> <div class="box3">box3</div> .box1{ border: 2px solid red; width: 40px; height:100px; float:left; } .box2{ border: 6px solid black; width:100px; height:40px; float:left; } .box3{ border: 12px solid blue; width:100px; height:300px; float:left; } (2) Make inline elements support width and height <span class="box1"></span> .box1{ border: 2px solid red; width: 40px; height:100px; float:left; } 3. When width or height is not set, the width and height are extended by the content; <span class="box1">hello</span> .box1{ border: 2px solid red; float:left; } 4. If you add float to an element, it will be out of the standard document flow (document flow refers to the position of the object in the document) and will look for non-floating elements to cover it (floating backwards), and it will have nothing to do with the previous elements. <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> .box1{ border: 1px solid red; width: 40px; height:100px; float:left; } .box2{ border: 4px solid blue; width: 140px; height:40px; float:left; } .box3{ border: 8px solid gray; width: 200px; height:200px; } 5. If an element is floated, it will first leave the standard flow and then float according to the floating direction until it hits the boundary of the previous floating element and stops, or falls down because the previous layer cannot accommodate the element and is placed on the next line; <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> .box1{ border: 11px solid red; width: 40px; height:100px; float:right; } .box2{ border: 4px solid blue; width: 140px; height:40px; float:left; } .box3{ border: 8px solid gray; width: 200px; height:200px; } 6. When an element A floats on an element B that does not float, it will squeeze out the original position of B's content, or even squeeze out <div class="box1">box1</div> <div class="box2">box2</div> <div class="box3">box3</div> .box1{ border: 11px solid red; width: 40px; height:100px; } .box2{ border: 4px solid blue; width: 60px; height:100px; float:left; } .box3{ border: 8px solid gray; width: 200px; height:200px; } When analyzing, if an element is floating, only look at the element in front of it. If the previous element is also floating, it will be displayed side by side. If the previous element is not floating, the relative position will remain unchanged. Detailed analysis: https://www.jb51.net/web/76691.html The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Introduction and use of triggers and cursors in MySQL
>>: HTML is something that web page creators must learn and master.
Table of contents Preface 1. ss command 2. Overal...
As a newbie who has just come into contact with t...
1. Download the Linux version from the official w...
Environment Preparation Before starting any opera...
Table of contents 1. Two-way binding 2. Will the ...
Docker installation Install dependency packages s...
The definition and inheritance of classes in JS a...
1. Background Generally, in a data warehouse envi...
I designed and customized a navigation bar with a...
When installing Tomcat in Docker, Tomcat may over...
1. Environmental Preparation 1.1 Basic Environmen...
1. px px is the abbreviation of pixel, a relative...
Table of contents Presentation Layer Business Lay...
1. Download the ElasticSearch 6.4.1 installation ...
Download and install. First check whether there i...