<style> .clearfix:before, .clearfix:after{ content: ' '; display: table; } .clearfix:after{ clear:both; } .wrap{ width: 100%; height: 200px; background-color: #fff; float: left; } .main{ height: 200px; margin-left: 210px; background-color: #378; } .side{ float: left; margin-left: -100%; width: 200px; height: 200px; background-color: #cccccc;} .footer{ width: 100%; height: 100px; background-color: #eee; } .container{padding:0 220px 0 200px;} .middle,.left,.right{ position:relative; float: left; min-height: 300px; } .middle{background-color: red;width:100%;} .left{width:200px;background-color: yellow;margin-left:-100%;left:-200px;} .right{width:220px;background-color: blue;margin-left:-220px;right:-220px;} </style> </head> <body> <h3>使用margin负值法进行布局</h3> <div class="clearfix"> <div class = "wrap"> <div class = "main">右侧主栏</div> </div> <div class = "side">左侧副栏</div> </div> <div class="footer"> 底部 </div> <div class="container"> <div class="middle"> <h4>我是middle</h4> </div> <div class="left"> <p>我是left的内容</p> </div> <div class="right"> <p>我是right的内容</p> </div> </div>
两栏布局
最新推荐文章于 2023-10-26 11:34:44 发布