we divide the common layout format of the webpage into the following three kinds:1. Standard flow.
The so-called standard flow is that the inline elements own a single line, and the block-level elements are displayed up and down.
We used to learn the standard flow.
Note: Standard flow makes the most stable structure in our web page layout
2. Floating Stream
Let us learn the first way out of the standard flow. Will affect the arrangement of our standard flow. So, when we lay out, we can do it with the standard flow, so we don't have to float.
3. Locating the stream
The location flow is also a pattern out of the standard stream. It is completely out of standard flow and does not affect the standard flow.
float (float)
we want to float: The purpose of our float is to put multiple block-level elements on the desired line.
float float: Left Right None
You have to be aware of the detailed understanding of floating:
1. Float has been detached from the standard stream. (Off-label)
In other words, floats are already floating above the standard flow.
2. Because our float is left and right floating, so our block-level elements are arranged left and right.
Clear Floating (clear)
If we want to do a good job of Web browser compatibility, the first thing to ensure that we write code to be enough standard.
Reason for clearing floats: because floats affect the standard flow. So I want to clear the float according to different situations.
Clear:both;
1.1.1 Additional Labeling method
It is recommended to add a new label to the back of the last floating box. Then he can clear the float.
Advantages: Popular Good understanding
Cons: Too many tags added
1.1.2Overflow Clear Float
Usage: Is floating large box (parent label) again style inside add: Overflow:hidden; In order to take care of IE6, we add zoom:1;
Advantages: Easy Code Writing
Cons: If the parent box has a positioning inside, it can cause trouble.
1.1.3 after pseudo class clear float
- Declare clear float:
. clearfix:after{
Content: "";
Display:block;
Visibility:hidden;
Clear:both;
height:0;
}
. clearfix{/* To take care of IE6 browser */
Zoom:1;
}
- Call
<div class= "box Clearfix" >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>overflow Clear Floating </title>
<style type= "Text/css" >
. clearfix:after{
Content: "";
Display:block;
Visibility:hidden;
Clear:both;
height:0;
}
. clearfix{/* To take care of IE6 browser */
Zoom:1;
}
. box{width:400px;}
one,.two{width:200px; height:100px; Background-color: #093; float:left;}
. Two{background-color: #39F;}
. test{width:400px; height:120px; Background-color: #900;}
</style>
<body>
<div class= "box Clearfix" >
<div class= "One" ></div>
<div class= "both" ></div>
</div>
<div class= "Test" ></div>
</body>
Advantages: Once written, directly after the call can be
Cons: Statement trouble writing
1.1.4After before pseudo-class clear float
- Declaration cleanup
.clearfix:before,.clearfix:after{
Content: "";
display:table;
}
. clearfix:after{
Clear:both;
}
. clearfix{ /* care ie6*/
zoom:1;
}
using:
<div class= "Box clearfix";
The above hope is helpful to everyone.
Xiao Qiang 00 and everyone to share.