cle*_*tus 19
将其更改为:
<div style="background-color:black; overflow:hidden;" onmouseover="this.bgColor='white'">
<div style="float:left">hello</div>
<div style="float:right">world</div>
</div>
Run Code Online (Sandbox Code Playgroud)
基本上外部div只包含浮点数.浮子从正常流动中移除.因此,外部div实际上没有任何东西,因此没有高度.它真的很黑,但你看不到它.
overflow:hidden属性基本上使外部div包含浮点数.另一种方法是:
<div style="background-color:black" onmouseover="this.bgColor='white'">
<div style="float:left">hello</div>
<div style="float:right">world</div>
<div style="clear:both></div>
</div>
Run Code Online (Sandbox Code Playgroud)
哦,只是为了完整性,你应该更喜欢类来引导CSS样式.