父亲浮动,子代也会跟着走
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="UTF-8"/> 5 <title>无标题文档</title> 6 <style> 7 #a{width:500px;height:500px;border:solid black 4px;} 8 p{width:100px;height:100px;background:yellow;} 9 .s{float:right;width:200px;height:200px;background:red;} 10 </style> 11 </head> 12 <body> 13 <div id="a"> 14 <div class="s"> 15 <p></p> 16 </div> 17 18 </div> 19 </body> 20 </html> 21 </html>
这个时候p也会到右边只不过紧贴着s的左边