1.要求:如上图中的,三栏目布局,中间的MAIN是自适应浏览器的宽度,左LEFT固定宽200PX,右RIGHT固定宽200PX;

.right,.left{height:300px;width:200px;}
.right{ float:right;background:#000000;}
.left{ float:left;background:#009933;}
.main{background:#F60; height:300px;}
     <div class="right">RIGHT</div>
    <div class="left">LEFT</div>
    <div class="main">MAIN</div>    

2.现在要求先加载MIAN,其它要求同上面一样;

总结:主要是利用浮动元素的负外边距;

  并且要理解float和绝对定位,这两种元素的宽度都是根据内容的宽度来的。

  相对定位和块级元素,如果不设定宽,都是100%(相对于父级的宽)

  DEMO下载

.boxmain{float:left;margin-right:-200px;width:100%;}
.right,.left{height:300px;width:200px; z-index:1;}
.right{ position:absolute; right:0; background:#000000;}
.left{position:absolute;left:0; background:#009933;}
.main{margin-right:200px;background:#F60; height:300px;margin-left:200px;}

 

    <div class="boxmain">
        <div class="main">main</div>    
    </div>
    <div class="left">LEFT</div>
    <div class="right">RIGHT</div>
posted on 2012-06-15 19:34  Ms.〢、洁 儿  阅读(172)  评论(0编辑  收藏  举报