Float attribute of the

the correct use of CSS may become a daunting task, it involves too much content, the browser compatibility problems are many. Positioning is not only involve   Containing block, but also involves a line box, box, and inline box, etc. This article contains the implementation of the example application properties of float illustrative example, and some of the mistakes.
code is as follows:


<Img SRC="http://lorempixum.com/200/200/"/>
<P> Lorem ipsum... </p>

they display in a new line:
code is as follows:


img
{
float: right;
margin: 20 px;
}

at this moment, we get the right alignment:
code is as follows:


{p
margin: 20 px;
}

in this way, it will be correct: as the chart
code is as follows:


img
{
margin: 20 px;
}

CSS float such as 5

so why do you ask the p paragraphs indented 20 pixels above will not work, does not take effect? To find out, let's add a framework code:
code is as follows:


{p
border: 1 px black solid;
}

the results may surprise you:
code is as follows:


img
{
float: right;
margin: 20 px;
}

{p
float: left;
width: 220 px;
margin: 20 px;
}

CSS float like 7

strange rules &other; Float”
code is as follows:


<Ul>
<Li> <Img SRC="http://placehold.it/100x100&text=1"/></li>
<Li> <Img SRC="http://placehold.it/100x150&text=2"/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=3"/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=4"/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=5"/></li>
<Li> <Img SRC="http://placehold.it/100x150&text=6"/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=7"/></li>
</ul>

by default, each li entry will be a line. If we are going to each &other; Float: left” , the image will be lining up a newline:

  code is as follows:  


li,
{
float: left;
margin: 4 px;
}

CSS float for example 8
code is as follows:


li,
{
display: inline;
}

CSS float for example 10
code is as follows:


img
{
vertical - align: TOP;
}

code is as follows:


<Ul>
<Li> <Img SRC="http://placehold.it/100x100&text=1"/></li>
<Li> <IMG SRC=http://www.jb51.net//web/“ http://placehold.it/100x100&text=2”/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=3"/></li>
<Li> <IMG SRC=http://www.jb51.net//web/“ http://placehold.it/100x100&text=4 &other;/></li>
<Li> <Img SRC="http://placehold.it/100x100&text=5"/></li>
<Li> <IMG SRC=http://www.jb51.net//web/“ http://placehold.it/100x100&text=6 &other;/></li>
</ul>

if we want them in the opposite order, we only need to use &other; Float: right: &throughout; Rather than &other; Float: left” Element. In HTML, we didn't change order as below code: we use CSS to operation

code is as follows:


ul li: the NTH - child (2)
{
clear: left;
}

here are we get:
code is as follows:


{p
clear: both;
}

to solve our question is:
code is as follows:


ul
{
background: gray;
}

CSS float such as 19  
but if we add &other; Float: left” Completely disappear from the list of background:
CSS float such as 20

if we first set the height to UL:

  code is as follows:  


UL
{
height: 300 px;
}

CSS float such as 21  
it does not solve the problem, since the size of the background is defined. Class &other; Clearfix” , which will be applied to 'DIV' elements in the same level of UL, can help us.
code is as follows:


clearfix
{
clear: both;
}

there is another solution, use &other; Overflow” :

  code is as follows:  


ul
{
overflow: auto;
}

CSS float example 22# 0 - #


This concludes the body part