<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS练习</title> <style> .parent{ border: 10px solid yellow; } .w100{ width:100px; height:100px; } .one{ background: red; float: left; } .tow{ background: skyblue; float: right; } .clearfix::after{ content:''; display: block; clear: both; } </style> </head> <body> <div class="parent clearfix"> <div class="w100 one"></div> <div class="w100 tow"></div> </div> <div style="height:200px;background:black"></div> </body> </html>
解决浮动造成的高度塌陷
最新推荐文章于 2022-11-29 20:49:33 发布