/固定宽度的布局/
/流式布局(按照%比)/
/弹性布局,根据字体 em进行布局/
1:一列自适应: width:80%;
<h5>一列固定居中: margin:0 auto;</h5> <h5>二列固定宽度:</h5> <div id="two-row" class="clearFix"> <style> .clearFix:after{ content:""; display:block; visibility:visible; clear:both; height:0; } #two-row { width:500px; background:#666 } #two-row .left{ width:200px; background:#0C9; float:left; } #two-row .right{ width:300px; background:#069; float:left; } </style> <div class="left">row1</div> <div class="right">row2</div> </div>
2:两列宽度自适应:利用左右定位;中间居中
<div id="two-auto" class="clearFix"> <style> .clearFix:after{ content:""; display:block; visibility:visible; clear:both; height:0; } #two-auto { background:#666 } #two-auto .left{ width:35%; background:#0C9; float:left; } #two-auto .right{ width:30%; background:#069; float:left; } </style> <div class="left">auto-left</div> <div class="right">auto-right</div> </div> 3:两列右列宽度自适应 <div id="right-auto"> <style> #right-auto{ } #right-auto .left{ width:100px; float:left; background:#ccc; } #right-auto .right{ background:#f00; border:2px solid #000; } </style> <div class="left">left</div> <div class="right">right</div> </div> <h5>三列自适应</h5> <div id="three"> <style> #three{ position:relative; } #three .left{ position:absolute; left:0;top:0; width:100px; height:300px; background:#C99; } #three .right{ position:absolute; top:0;right:0; width:100px; height:300px; background:#C99; } #three .center{ margin-left:100px; margin-right:100px; height:300px; background:#F03; } </style> <div class="left">left</div> <div class="right">right</div> <div class="center">center</div> </div> <h5>三列自适应;利用左右浮动;中间居中</h5> <div id="three-1"> <style> #three-1{ position:relative; } #three-1 .left{ float:left; width:100px; height:300px; background:#C99; } #three-1 .right{ float:right; width:100px; height:300px; background:#C99; } #three-1 .center{ margin-left:100px; margin-right:100px; height:300px; background:#F03; } </style> <div class="left">left</div> <div class="right">right</div> <div class="center">center</div> </div>
转载于:https://www.cnblogs.com/diligenceday/p/3972192.html
相关资源:JAVA上百实例源码以及开源项目