码迷,mamicode.com
首页 > 其他好文 > 详细

圣杯布局和双飞翼布局

时间:2019-08-27 22:40:33      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:round   ons   div   red   osi   简洁   页面   containe   head   

区别就是一个采用大包三个小,用了相对布局,另一个大包中间的一个,不需要使用定位,更加简洁,且允许的页面最小宽度通常比圣杯布局更小。

圣杯布局:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>圣杯</title>
    <style>
        #foot{
            clear: both;
        }
        #container{
            padding: 0 150px 0 200px;
        }
        #main{
            width: 100%;
            background-color: red;
        }
        #left{
            width: 200px;
            background-color: yellow;
            margin-left: -100%;
            position: relative;
            left: -200px;
        }
        #right{
            width: 150px;
            background-color: blue;
            margin-right: -150px;
        }
        .ele{
            height: 500px;
            float: left;
        }
    </style>
  </head>
  <body style="padding: 0;">
     <!-- 圣杯布局(float + 负margin + padding + position) -->
    <div></div>
    <div id="container">
        <div id="main" class="ele">1</div>
        <div id="left" class="ele">2</div>
        <div id="right" class="ele">3</div>
    </div>
    <div id="foot"></div>
    <script>
        console.log(...[1, 2, 3], [1, 2, 3]);
    </script>
  </body>
</html>

 

双飞翼:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>双飞翼</title>
    <style>
        #foot{
            clear: both;
        }
        #container{
            width: 100%;
        }
        #main{
            height: 100%;
            margin-left: 200px;
            margin-right: 150px;
            background-color: red;
        }
        #left{
            width: 200px;
            background-color: yellow;
            margin-left: -100%;
        }
        #right{
            background-color: blue;
            width: 150px; 
            margin-left: -150px;
        }
        .ele{
            height: 500px;
            float: left;
        }
    </style>
  </head>
  <body style="padding: 0;">
    <div></div>
    <div id="container" class="ele">
        <div id="main">1</div>
    </div>
    <div id="left" class="ele">2</div>
    <div id="right" class="ele">3</div>
    <div id="foot"></div>
    <script>
        console.log(...[1, 2, 3], [1, 2, 3]);
    </script>
  </body>
</html>

 

圣杯布局和双飞翼布局

标签:round   ons   div   red   osi   简洁   页面   containe   head   

原文地址:https://www.cnblogs.com/qq965921539/p/11421077.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!