页面常用布局

1.固定三列
<!DOCTYPE html>
<html>
   <head>
      <title>固定三列</title>
      <style type="text/css">
         body{
            margin-left:auto;
            margin-right:auto;
            width:900px;
         }
         .left{
            width: 200px;
            background-color: red;
            height: 500px;
            float: left;
         }
         .center{
            width: 500px;
            background-color: blue;
            height: 500px;
            float: left;
         }
         .right{
            width:200px;
            background-color: green;
            height: 500px;
            float: left;
         }
      </style>
   </head>
   <body>
      <div class='left'></div>
      <div class='center'></div>
      <div class='right'></div>
   </body>
</html>
2.三列,定高,左右定宽,中间自适应
<!DOCTYPE html>
<html>
   <head>
      <title>定高,左右定宽,中间自动</title>
      <style type="text/css">
         .left{
            width: 200px;
            background-color: red;
            float: left;
            height: 500px;
         }
         .center{
            background-color: blue;
            margin-left: 200px;
            height: 500px;
            margin-right: 200px;
         }
         .right{
            width: 200px;
            background-color: green;
            float: right;
            margin-top: -500px;
            height: 500px;
         }
      </style>
   </head>
   <body>
      <div class='left'></div>
      <div class='center'></div>
      <div class='right'></div>
   </body>
</html>
3.三列,不定高,左右定宽,中间自适应
<!DOCTYPE html>
<html>
   <head>
      <title>不定高,左右定宽,中间自适应</title>
      <style type="text/css">
         .left{
            width: 200px;
            background-color: red;
            position: absolute;
            top:0px;
            left:0px;
            height: 500px;
         }
         .center{
            background-color: blue;
            margin-left: 200px;
            height: 500px;
            margin-right: 200px;
         }
         .right{
            width: 200px;
            background-color: green;
            position: absolute;
            right: 0px;
            top:0px;
            height: 300px;
         }
      </style>
   </head>
   <body>
      <div class='left'></div>
      <div class='center'></div>
      <div class='right'></div>
   </body>
</html>
4.两列,左定宽,右自适应
<!DOCTYPE html>
<html>
   <head>
      <title>左定宽,右自适应</title>
      <style type="text/css">
         .left{
            width: 200px;
            background-color: red;
            height: 500px;
            float:left;
         }
         .right{
            width:auto;
            background-color: green;
            margin-left:200px;
            height: 500px;
         }
      </style>
   </head>
   <body>
      <div class='left'></div>
      <div class='right'></div>
   </body>
</html>
5.两列,右定宽,左自适应
<!DOCTYPE html>
<html>
   <head>
      <title>右定宽,左自适应</title>
      <style type="text/css">
         .left{
            width: 200px;
            background-color: red;
            height: 500px;
            margin-right: 200px;
            width:auto;
         }
         .right{
            width: 200px;
            background-color: green;
            height: 500px;
            float:right;
         }
      </style>
   </head>
   <body>
      <div class='right'></div>
      <div class='left'></div>
   </body>
</html>
 欢迎各位看官贴出更好的布局类型和方法!

转载于:https://www.cnblogs.com/liu-liang/archive/2013/05/10/3071039.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值