1
.float1 { float: left; width: 50%; height: 50%; } .float2 { float: right; width: 50%; height: 50%; } .float3 { float: left; width: 50%; height: 50%; } .float4 { float: right; width: 50%; height: 50%; } .clear { clear: both; }
HTML:
<div class="float1">Float 1</div> <div class="float2">Float 2</div> <div class="clear"></div> <div class="float3">Float 3</div> <div class="float4">Float 4</div> <div class="clear"></div>
我想这样的形象输出:
CSS的float声明
请纠正我的CSS代码。 谢谢。
如果FLOAT3是两个明确的,怎么会FLOAT4是正确的旁边? – 2010-04-30 18:58:36
@Matt:'clear'影响前面的元素,而不是后面的元素。 – 2010-04-30 19:04:18
我喜欢重构的CSS,与上面提到的不同。但我常常怀疑使用高度或宽度。 – phoenix24 2010-04-30 19:28:30