<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <html> <style> .box { width: 200px; background: #bfa; border: 2px dashed red; } .box2 { width: 100px; height: 100px; margin: 20px; background-color: orange; float: right; } .box3 { width: 100px; height: 100px; margin-top: 10px; background-color: rgb(206, 188, 154); } clearfix::after, clearfix::before { content: ''; display: table; clear: both; } .clearfix::before, .clertfix::after { content: ''; display: table; clear: both; } </style> <body> <div class="box clearfix"> <div class="box2"></div> <div class="box3"></div> </div> </body> </html>
标签:浮动,clearfix,清除,100px,height,width,background,方法,color From: https://www.cnblogs.com/overspread/p/16774098.html