自己总结了一下
1、左侧固定,右侧自适应
2、右侧固定,左侧自适应
3、左右两侧固定,中间自适应
<body class="sqh_bg_fafafa"> <div>左侧固定,右侧自适应</div> <div> <div style="width: 200px;float: left;border: 1px solid red;">width: 200px;float: left</div> <div style="margin-left: 201px;border: 1px solid blue;">margin-left: 201px</div> </div> <hr> <div>右侧固定,左侧自适应</div> <div> <div style="width: 200px;float: right;border: 1px solid red;">width: 200px;float: left</div> <div style="margin-right: 201px;border: 1px solid blue;">margin-left: 201px</div> </div> <div style="color: red">注意:右边的div代码一定要是写在左边代码的上面,float:right代码,注意代码顺序,否则代码不正确</div> <div style="height: 20px;"></div> <div> <div style="margin-right: 201px;border: 1px solid blue;">margin-left: 201px</div> <div style="width: 200px;float: right;border: 1px solid red;">width: 200px;float: left</div> </div> <hr> <div>左右固定,中间自适应</div> <div> <div style="width: 200px;float: left;border: 1px solid red;">width: 200px;float: left</div> <div style="margin-left: 201px;"> <div style="float: right;width: 200px;border: 1px solid blue;">float: right;width: 200px;</div> <div style="margin-right: 201px;border: 1px solid green;">margin-right: 201px;</div> </div> </div> <div style="height: 20px;"></div> <div> <div style="width: 200px;float: right;border: 1px solid red;">width: 200px;float: left</div> <div style="margin-right: 201px;"> <div style="float: left;width: 200px;border: 1px solid blue;">float: left;width: 200px;</div> <div style="margin-left: 201px;border: 1px solid green">margin-left: 201px;</div> </div> </div> </body>
<li class="sqh_overflow_hidden sqh_relative border_b_bottom_eee padding_top_10 padding_bottom_10" > <div style="width: 20px;" class="float_right" target="http://www.baidu.com"> <div class="icon iconfont sqh_absolute sqh_position_top_20" ></div> </div> <div class="sqh_line_height_15 sqh_overflow_hidden" style="margin-right: 20px"> <div class="float_left width_70px padding_left_10"> 险种名称 </div> <div class="margin_left_75"> <input type="text" class="all_width clear_border" > </div> </div> </li>
<style> .sqh_pointer { cursor: pointer; } .float_right { float: right; } .sqh_overflow_hidden { overflow: hidden; } .sqh_line_height_15 { line-height: 1.5; } .width_70px { width: 70px; } .padding_left_10 { padding-left: 10px; } .margin_left_75 { margin-left: 75px; } .all_width { width: 100%; } .clear_border { border: medium none !important; } .border_b_bottom_eee { border-bottom: 1px solid #eeeeee; } .sqh_relative { position: relative; } .padding_bottom_10 { padding-bottom: 10px; } .padding_top_10 { padding-top: 10px; } </style>
原理说明
- 右侧固定宽度,左侧百分百
- 以左侧为父div,子div 左侧固定,右侧百分百