返回html页面三......登陆

html页面三列布局左右绝对定位中间自适应

2019-04-26 00:01:30341

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

<title>三列布局左右绝对定位中间自适应</title>

<style type="text/css">

    body {           /*初始样式。用于相对定位relative*/

     margin: 0;

     padding: 0;

    }

    .container {

     position: absolute;      /*设置绝对定位时必须要设置左右两边顶点*/

     left: 0;

     right: 0;


    }

         .left {

          position: absolute;   /*绝对定位*/

          top: 0;

          left: 0;

          width: 200px;

          height: 600px;

          background-color: red;


         }

         .right {

          position: absolute;   /*绝对定位*/

          top: 0;

          right: 0;

          width: 200px;

          height: 600px;

          background-color: yellow;

         }

         .main {

            height: 600px;

            margin-left: 200px;

            margin-right: 200px;

            background-color: blue;


         }

</style>

</head>

<body>

     <h2></h2>

     <p>1.左右两列采用约定定位布局<br>

        2.中间内容不更采用margin挤压出来

     </p>

     

<div class="container">

          <div class="left">左侧</div>

          <div class="right">右侧</div>

          <div class="main">主体</div>

     </div>

</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送