Continue, when a group of floating elements encounters that there is not enough space on the right, it will automatically go down and will not leave the outermost layer. That is to say, although it will not follow the flow pattern on the ground, it will still follow the flow in the air. Pattern, ps: they all float at the same height. .
<html> <head> <style type="text/css"> body{ margin:0; padding:0; } #a{ width:500px; height:500px; border:solid; } .div{ width:100px; height:100px; border:soild; margin:5px; background:green; float:left; } #b{ width:100px; height:100px; border:soild; background:green; float:left; margin:5px; } </style> <head> <body> <div id="a"> <div id="b"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> </div> </body> </html>
This shows the same in Firefox and IE6
What happens when the first floating div is taller than other floating divs?
<html> <head> <style type="text/css"> body{ margin:0; padding:0; } #a{ width:500px; height:500px; border:solid; } .div{ width:100px; height:100px; border:soild; margin:5px; background:green; float:left; } #b{ width:100px; height:110px; border:soild; background:green; float:left; margin:5px; } </style> <head> <body> <div id="a"> <div id="b"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> </div> </body> </html>
You will find that the last one is stuck there. It will not squeeze through. If you squeeze it hard, it will crash, right? The div still needs to be polite, but It will also not automatically adjust the top margin to the left, because it is not that smart yet and needs to be adjusted manually. If it can run automatically, it will be a bunker, right? .
Let’s look at an example
<html> <head> <style type="text/css"> body{ margin:0; padding:0; } #a{ width:500px; height:500px; border:solid; } #b{ width:130px; height:350px; border:soild; background:green; float:left; margin:5px; } #c{ width:350px; height:350px; border:soild; background:green; float:left; margin:5px; } </style> <head> <body> <div id="a"> <div id="b"></div> <div id="c"></div> </div> </body> </html>
This is the structure of a general web page, the head is not done, here is the middle, the left is the list, and the right Display content
Now get the tail
I want to get this effect
The code is as follows
<html> <head> <style type="text/css"> body{ margin:0; padding:0; } #a{ width:500px; height:500px; border:solid; } #b{ width:130px; height:350px; border:soild; background:green; float:left; margin:5px; } #c{ width:350px; height:350px; border:soild; background:green; float:left; margin:5px; } #d{ width:490px; height:100px; border:soild; background:red; float:left; margin:5px; } </style> <head> <body> <div id="a"> <div id="b"></div> <div id="c"></div> <div id="d"></div> </div> </body> </html>
But many people forget to add float at the bottom layer :left;
That’s it
#d{ width:490px; height:100px; border:soild; background:red; margin:5px; }
The result will be like this
Remember what I said before, the div on the ground will not know the existence of the div in the sky, So I don’t know that the floating div has occupied the area.
In addition to adding float:left;
to the bottom layer, there is another way, which is clear
clear means to clear the float. I didn’t understand it at first, and probably most people don’t understand it either.
Clearing here does not mean deleting the floating div, nor does it change its position.
It should be understood this way.
Add clear to an ordinary div. , which is equivalent to installing an eye that can see the air. The div on the ground can see the situation of the div in the air, so as to know what area the div in the air occupies, so as to avoid occupying the area of the div in the air.
clear There are left right, both, and none attributes. The default is none, which means it is not set.
left means you can see the upper left space of the div on the ground itself, and right is the upper right space.
both means both sides, generally use both
<html> <head> <style type="text/css"> body{ margin:0; padding:0; } #a{ width:500px; height:500px; border:solid; } #b{ width:130px; height:350px; border:soild; background:green; float:left; margin:5px; } #c{ width:350px; height:350px; border:soild; background:green; float:left; margin:5px; } #d{ width:490px; height:100px; border:soild; background:red; margin:5px; clear:both; } </style> <head> <body> <div id="a"> <div id="b"></div> <div id="c"></div> <div id="d"></div> </div> </body> </html>
The above is the content of a new beginning of div+css web layout design (8). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

I got this question the other day. My first thought is: weird question! Specificity is about selectors, and at-rules are not selectors, so... irrelevant?

Yes, you can, and it doesn't really matter in what order. A CSS preprocessor is not required. It works in regular CSS.

You should for sure be setting far-out cache headers on your assets like CSS and JavaScript (and images and fonts and whatever else). That tells the browser

Many developers write about how to maintain a CSS codebase, yet not a lot of them write about how they measure the quality of that codebase. Sure, we have

Have you ever had a form that needed to accept a short, arbitrary bit of text? Like a name or whatever. That's exactly what is for. There are lots of

I'm so excited to be heading to Zürich, Switzerland for Front Conference (Love that name and URL!). I've never been to Switzerland before, so I'm excited

One of my favorite developments in software development has been the advent of serverless. As a developer who has a tendency to get bogged down in the details

In this post, we’ll be using an ecommerce store demo I built and deployed to Netlify to show how we can make dynamic routes for incoming data. It’s a fairly


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

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.

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment