为什么设置子元素浮动后没有出现父元素塌陷?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>float演示案例</title> <style> *{ margin: 0; padding: 0} .container{ width: 790px; border: 1px dashed gray; padding:10px; /*overflow:hidden; zoom:1;没有出现父元素塌陷*/ } div{ width: 240px; margin: 10px; border: 1px solid gray; float: left; } p{ margin:5px} </style> </head> <body> <div class="container"> <div> <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg" alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> <div> <img src=http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> <div> <img src=http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> <div> <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg" alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> <div> <img src=http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> <div> <img src=http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg alt="html"> <p>欢迎来到慕课网学习新知识!</p> </div> </div> </body> </html>
0
收起
正在回答 回答被采纳积分+1
2回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星