浮动
清除浮动的最好办法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .box{ border:1px solid red; } .box:after{ /*通过给父级加上after伪类,清楚浮动*/ content: ''; display: block; clear: both; } .item{ width: 200px; height: 200px; background: black; float: left; } </style> </head> <body> <div class="box"> <div class="item"></div> </div> </body> </html>