Detailed examples of float usage in HTML/CSS

Detailed examples of float usage in HTML/CSS

1. Basic usage examples of float

1. Let's first create two div boxes and set the height, width and background color;

The initial positions of the two boxes on the web page are as follows:

Then we float the red box to the right

Then we will find that the red box floats to the right, but the blue box moves directly up to the original position of the red box.

Then we float the blue box to the right to see the effect:

We will find that it will be arranged closely following the red box and will not be affected by the block-level elements and occupy a single line.

2. Basic rules of floating positioning

1. When the float attribute of an element is left or right, the element is floating;

2. If there is not enough space left to hold the floating box, the box moves down until there is enough space to hold the box, and then moves left or right;

3. The top edge of the floating box must not be higher than the top edge of the previous box;

4. When placing floating boxes, avoid regular flow boxes; when placing regular flow boxes, ignore floating boxes;

5. When calculating the automatic height of the regular flow box, the floating box is ignored

6. Clear float: clear:both (left or right).

Summarize

The above is a detailed example of the usage of float in HTML/CSS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  Web Design Tutorial (7): Improving Web Design Efficiency

>>:  How to make spaces have the same width in IE and FF?

Recommend

Detailed explanation of the use of MySQL paradigm

1. Paradigm The English name of the paradigm is N...

How to use the Linux more command in Linux common commands

more is one of our most commonly used tools. The ...

mysql query data for today, this week, this month, and last month

today select * from table name where to_days(time...

Detailed explanation of the method of comparing dates in MySQL

If there is a table product with a field add_time...

The difference between Display, Visibility, Opacity, rgba and z-index: -1 in CSS

We often need to control the hidden, transparent ...

Web Design Tutorial (1): Steps and Overall Layout

<br /> Note: All texts, except those indicat...

Interactive experience trends that will become mainstream in 2015-2016

The most important interactive design article in ...

How to use Cron Jobs to execute PHP regularly under Cpanel

Open the cpanel management backend, under the &qu...

How to deploy LNMP architecture in docker

Environmental requirements: IP hostname 192.168.1...

How to optimize the slow Like fuzzy query in MySQL

Table of contents 1. Introduction: 2. The first i...

A detailed introduction to seata docker high availability deployment

Version 1.4.2 Official Documentation dockerhub st...

MySQL 8.0.12 installation graphic tutorial

MySQL8.0.12 installation tutorial, share with eve...

Specific usage instructions for mysql-joins

Table of contents Join syntax: 1. InnerJOIN: (Inn...