解決子級用css float浮動 而父級div沒高度不能自適應高度

1.使用css clear清除浮動;

在父級div體內添加子級div<div style="clear:both;"/> css

2.對父級樣式加overflow:hidden。

<div style="overflow:hidden;"/>(PS:爲何是hidden?反其道而行之?) html


PS spa

1.clear 屬性規定元素的哪一側不容許其餘浮動元素。 ssr

可能值:left、right、both、none(默認值)、inherit htm

2.overflow 屬性規定當內容溢出元素框時發生的事情。 it

可能值:auto、scroll、hidden、visible(默認值)、inherit scroll


參考文獻: float

1.解決子級用css float浮動 而父級div沒高度不能自適應高度-http://www.divcss5.com/jiqiao/j612.shtml 自適應

2.CSS 參考手冊-http://www.w3school.com.cn/cssref/index.asp 樣式

相關文章
相關標籤/搜索