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

Original 2019-04-26 00:01:30 342
abstract:<!DOCTYPE html><html><head>    <meta charset="utf-8"><title>三列布局左右绝对定位中间自适应</title><style type="text/css">    body { &

<!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>


Correcting teacher:查无此人Correction time:2019-04-26 13:24:50
Teacher's summary:完成的不错,刚接触编程,比较辛苦。要坚持,继续加油。

Release Notes

Popular Entries