CSS 实现一侧固定宽度,另一侧自动宽度
ITPOW2017/3/6 15:57:58
如下代码:一个是左侧固定宽度,右侧自动宽度;另一个是右侧固定宽度,左侧自动宽度。
<div style="width:500px; overflow:hidden; background:#999;"> <div style="float:left; width:100px; background:#f66;">left</div> <div style="margin-left:110px; background:#6f6;">right</div> </div> <div> </div> <div style="width:500px; overflow:hidden; background:#999;"> <div style="float:right; width:100px; background:#f66;">right</div> <div style="margin-right:110px; background:#6f6;">left</div> </div>
实现方法:一侧 float,另一侧不 float。
使用 float 的,固定宽度。
使用 float 的,写在前面,比如前面第二段代码。
没有使用 float 的,使用 margin。
<<返回首页<<