Document Flow: The browser arranges the elements in the order in which they appear in the HTML document, from left to right, from top to bottom.
The floating property is the positional property in the CSS, and is used as follows:
float: Floating direction (left, right, none);
Left is floating, right is floating, none is the default value means no float
sets the float of an element that moves away from the document stream, left or right
Until its outer margin touches the border of the parent element or the edge of another floating element
Box until
Float usage (primarily for block-level elements):
1, blocks block-level element does not specify width, the default is 100% (that will occupy a whole line).
2, blocks block-level element does not specify width but after adding float float, its width will change dynamically according to its content length, other block-level elements may be added to the left or right.
3, block-level element specifies width but after adding float float, its width does not change dynamically according to its content length (the text may overflow), other block-level elements may be added to the left or right.
4. Block-level elements added to float float away from the standard document stream, moving left or right until its margin touches the border of the parent element or the border of another floating element.
Example code:
<! DOCTYPE html>
<title>demo</title>
<style type= "Text/css" >
body{
margin:0px Auto;
padding:0px;
}
. container{
width:500px;
height:500px;
border:1px solid red;
margin:0px auto;/* Main Panel Div Center */
}
. header{
height:100px;
border:1px solid red;
Float:left; /* Add floating */
}
. main{
height:100px;
width:100px;
border:1px solid red;
Float:left; /* Add floating */
}
. footer{
height:100px;
width:100px;
border:1px solid red;
Float:right; /* Add floating */
}
</style>
<body>
<div class= "Container" >
<div class= "Header" >
Head
</div>
<div class= "Main" >
Middle
</div>
<div class= "Footer" >
Foot part
</div>
</div>
</body>
Float usage in CSS