Floating in DIV CSS is divided into left floating, right floating and clear floating. 1. Right floating. The so-called right floating means that a block element moves to the right to give up its own space and moves to the right until it encounters Contains the rightmost border of its own parent element. As shown in the figure below:
The test code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title> 浮动案例 </title> <link rel="stylesheet" style="text/css" href="float.css"/> </head> <body> <div class="div1" id="id1">div1</div> <div class="div1">div2</div> <div class="div1">div3</div> </body></html>
.div1{ width:150px; height:100px; border:1px solid red; background:pink; margin-top:5px;}/*id 选择器*/#id1{ float:right;}