CSS has two functions for clearing floats:
(1) You can surround elements to "visually" wrap floating elements
(2) Other elements under clearing will return to the default layout.
Note:
If there is floating, there must be clearing.
If the surrounding element has a specified height, then the clearing function does not need to be used.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>php.cn</title>
<style type="text/css">
img{
width:200px;
float:left;
}
.clear{clear:left;}
</style>
</head>
<body>
<h1>习近平心中的互联网</h1>
<p>互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。</p>
<img src="http://img.kanzhun.com/upload/image/20150616/ccd02d7d2bcf7451de277579c453ccde.jpg" >
<div class="clear"></div>
<p>互联网是20世纪最伟大的发明,它正在将人类“一网打尽”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。</p>
</body>
</html>Note: You can try to delete the statement that clears floats and see if there are any changes in the output
Next Section