• 圣杯布局


    今天去阿里面试的时候被问到这个了。。。当时表示没听说过,然后让面试官给我解释了一下,回来继续补习。

    首先上代码:

    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
    .main {
        background:#D6D6D6;
    }
    
    .left {
        background:#E79F6D;
    }
    
    .right {
        background:#7BD;
    }
    
    /* core layout css */
    .main {
        float:left;
        width:100%;
    }
    
    .left {
        float:left;
        width:190px;
        margin-left:-100%;
    
    }
    
    .right {
        float:left;
        width:230px;
        margin-left:-230px;
    
    }
    .in{margin:0 230px 0 190px}
    
    </style>
    
        </head>
    <body>
    <div id="bd">
                  <div class="main"><div class="in">test11111111111</div></div>
                  <div class="left">test11111111111</div>
                  <div class="right">test11111111111</div>
             </div>
    </body>
    </html>

    核心思想是利用margin负边距进行挤呀挤:

    负边距  margin-left为负值,且两个元素不在一行的时候(可以用元素float:left,100%实现)margin-left可以吃掉兄弟元素的margin.

  • 相关阅读:
    文本属性和属性连写
    并集选择器
    子代选择器
    后代选择器
    交集选择器
    xpath helper 表格爬取
    爬取xiachufang图片试手
    bs4 beautifullsoup网页内容选择器
    requests第三方库使用 抓取
    python 爬虫学习
  • 原文地址:https://www.cnblogs.com/hongchenok/p/3973275.html
Copyright © 2020-2023  润新知