需求:
俩字符串,想在一行显示。一个左对齐,另一个右对齐。如图所示
实现代码:
<div>
<div style="float:left">北京市</div>
<div style="float:right">朝阳区</div>
</div>
<div style="clear:both"></div>
<div>
<div style="float:left">上海市</div>
<div style="float:right">浦东区</div>
</div>
<div style="clear:both"></div>
代码讲解:
浮动显示主要靠float:left和float:right来实现。
要注意的是,使用完要清除clear:both