问题描述
- css双浮动如何智能调节父标签的高度
- 如题,我只能做到根据第一个浮动调节父标签的高度,双浮动的话,如果第二个浮动比第一个高的话,就会溢出。不要让我隐藏第二个浮动溢出的部分,我需要能够全部显示
解决方案
参考A new micro clearfix hack
使用在父级元素使用clearfix样式
/** * For modern browsers * 1. The space content is one way to avoid an Opera bug when the * contenteditable attribute is included anywhere else in the document. * Otherwise it causes space to appear at the top and bottom of elements * that are clearfixed. * 2. The use of `table` rather than `block` is only necessary if using * `:before` to contain the top-margins of child elements. */.cf:before.cf:after { content: "" ""; /* 1 */ display: table; /* 2 */}.cf:after { clear: both;}/** * For IE 6/7 only * Include this rule to trigger hasLayout and contain floats. */.cf { *zoom: 1;}
当然,网上还有其他的跨浏览器的clearfix的写法,可以自己搜一下
解决方案二:
几种解决办法
http://www.divcss5.com/jiqiao/j612.shtml
时间: 2024-11-28 19:09:31