float value
Look at a chestnut
The red wireframe represents the parent element
It is out of the document flow. In fact, it is not completely out of the way, and will be blocked by the boundary of the parent element.
float elements are in the same document flow
Look at an example:
The red line box represents the parent element
After the three child elements "float to the left", the parent element has no content, so the parent element does not High.
float elements are semi-detached from the document flow
For elements, they are detached from the document flow; for content, they are in the document flow. The elements overlap, but the content does not.
Give me an example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>float元素半脱离文档流</title> <style type="text/css"> body{ width: 300px;padding: 5px;line-height: 1.6; border: 1px dashed blue; } .sample{ height: 100px;margin-right: 5px; padding: 0 5px; line-height: 100px;background-color: pink; } .sb{ outline: 1px dashed red; } .sample{ float: left; } </style> </head> <body> <div class="sample">float : left </div> <div class="sb"> A float is a box that is shifted to the left or right on the current line . the most interesting characteristic of a float (o "floated" o "floating" box) is that content may flow along its side (or be prohibited from doing so by the 'clear' property). </div> </body> </html>
Give me another example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>float abscure</title> <style type="text/css"> body{ width: 400px;line-height: 1.6; } .sample{ width: 100px;line-height: 100px; margin: 3px;text-align: center; background-color: pink; } .sb{ margin: 10px auto; padding: 5px; border: 1px dashed #0f00fa; } .sample{ float: left; } </style> </head> <body> <div class="sb"> <div class="sample">float: left;</div> 第十二届ChinaJoy 动漫游戏展7月31号在上海新国际博览中心开幕,导出是站台表演的帅哥美女。 </div> <div class="sb"> 有些游戏商为了吸引人气,还请来了著名的演员、模特前来助阵。以下是一批漂亮的Show Girl现场照片。 </div> </body> </html>
Usually we don’t want this result, but the pink div is only surrounded by the first text block. You need to use the clear attribute
clear
To understand clear, you must first know that div is a block-level element. It occupies an exclusive line in the page and is arranged from top to bottom, which is the legendary flow
① Applied to subsequent elements to clear the impact of floating on subsequent elements.
②Apply to block-level elements
Usage:
Add a blank element (less used)
clearfix, this is a general solution. In fact, an unavailable dot is used to clear the float.
For example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>float abscure</title> <style type="text/css"> body{ width: 400px;line-height: 1.6; } .sample{ width: 100px;line-height: 100px; margin: 3px;text-align: center; background-color: pink; } .sb{ margin: 10px auto; padding: 5px; border: 1px dashed #0f00fa; } .sample{ float: left; } .clearfix:after{ content: '.'; /* 在clearfix后面加入一个 . */ display: block; /* 设置 . 块级元素 */ clear: both; /* 清除浮动效果 */ /*隐藏那个 . */ height: 0; overflow: hidden; visibility: hidden; } /* .clearfix{ zoom: 1; 由于在IE 低版本中,不支持after属性,所以需要增加zoom属性 } */ </style> </head> <body> <div class="sb clearfix"> <div class="sample">float: left;</div> 第十二届ChinaJoy 动漫游戏展7月31号在上海新国际博览中心开幕,导出是站台表演的帅哥美女。 </div> <div class="sb"> 有些游戏商为了吸引人气,还请来了著名的演员、模特前来助阵。以下是一批漂亮的Show Girl现场照片。 </div> </body> </html>

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:


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

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.