浮动相关问题
浮动相关问题: 使得父元素包含子元素,常见的方式是为父元素设置overflow:hidden或浮动父元素。根本原因在于创建BFC的元素,子浮动元素也会参与其高度计算,即不会产生高度塌陷问题。实际上只要让父元素生成BFC即可,并不只有这两种方式。 复制代码<!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--><meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title></title> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; }#map{ padding:0;}.first{ margin:20px; background:lightgreen; border: 2px solid lightgreen; /*display:inline-block;*/ /*overflow:hidden;*/ /*float: left;*/ /*position: absolute;*/}ul{ overflow:hidden; margin:10px; background:lightblue; width:100px; height:200px; float: left;}li{ margin:25px;}</style> </head> <body class="claro"> <div class="first"> ...