zoukankan      html  css  js  c++  java
  • CSS布局(圣杯、双飞翼、flex)

    圣杯布局(float + 负margin + padding + position)

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title>圣杯</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .main{
                float: left;
                width: 100%;
                height: 500px;
                background:red;
            }
            .sub{
                position: relative;
                float: left;
                left: -200px;
                width: 200px;
                height: 500px;
                margin-left: -100%;
                background:blue;
            }
            .extra{
                position: relative;
                float: left;
                right: -180px;
                width: 180px;
                height: 500px;
                margin-left: -180px;
                background:green;
            }
            .content{
                padding: 0 180px 0 200px;
            }
        </style>
      </head>
      <body>
         <!-- 圣杯布局(float + 负margin + padding + position) -->
        <div class="content">
            <div class="main"></div>
            <div class="sub"></div>
            <div class="extra"></div>
        </div>
      </body>
    </html>

    双飞翼布局(float + 负margin + margin)

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title></title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .content{
                float: left;
                width: 100%;
                height: 500px;
                background:red;
            }
            .sub{
                float: left;
                width: 200px;
                height: 500px;
                margin-left: -100%;
                background:blue;
            }
            .extra{
                float: left;
                width: 180px;
                height: 500px;
                margin-left: -180px;
                background:green;
            }
            .main{
                margin: 0 180px 0 200px;
            }
        </style>
      </head>
      <body>
        <!--  双飞翼布局(float + 负margin + margin) -->
        <div class="content">
            <div class="main"></div>
        </div>
        <div class="sub"></div>
        <div class="extra"></div>
      </body>
    </html>

    flex布局

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title></title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .content{
                display: flex;
            }
            .sub{
                width: 200px;
                height: 500px;
                background:blue;
            }
            .main{
                flex:1;
                height: 500px;
                background:red;
            }
            .extra{
                width: 180px;
                height: 500px;
                background:green;
            }
        </style>
      </head>
      <body>
        <!--  flex布局 -->
        <div class="content">
            <div class="sub"></div>
            <div class="main"></div>
            <div class="extra"></div>
        </div>
      </body>
    </html>

    一样效果,不一样的布局。如下:

  • 相关阅读:
    lucene建立索引时候的用到的一些文档和目录操作
    MYSQL Cast函数 类型转换
    windows和linux下执行java程序+获取本机IP
    apache lucene 的核心类
    apache lucene 一个最简单的实例
    lucene 索引非txt文档 (pdf word rtf html xml)
    MyISAM & InnoDB
    软件开发者面试百问
    比较lucene各种英文分析器Analyzer
    浅谈Base64编码
  • 原文地址:https://www.cnblogs.com/zhang-wang/p/7472699.html
Copyright © 2011-2022 走看看