zoukankan      html  css  js  c++  java
  • 百分比布局 双飞翼布局 圣杯布局

    1.百分比布局:所有的百分比都是相对父级的

                       Div{ Width:50%;}div的宽是它父级元素的百分之五十

    2.双飞翼布局 

                 中间固定两边自适应

      <!DOCTYPE html>
      <html>
      <head>
        <meta charset="utf-8">
        <title>双飞翼布局</title>
        <style type="text/css">
          .left, .center, .right {
            float: left;
            min-height: 130px;
            text-align: center;
          }
          .left {
            margin-left: -100%;
            background: green;
             200px;
          }

          .right {
            margin-left: -300px;
            background-color: red;
             300px;
          }
          .center {
            background-color: blue;
             100%;
          }
          .center1{
            margin: 0 300px 0 200px;
          }
        </style>
      </head>
      <body>
        <div class="cont">
          <div class="center">
            <div class="center1">center</div>
          </div>
          <div class="left">left</div>
          <div class="right">right</div>
        </div>
      </body>
      </html>

    3.圣杯布局

             两端固定中间自适应

      

      <!DOCTYPE html>
      <html>
      <head>
        <meta charset="utf-8">
        <title>圣杯布局</title>
        <style type="text/css">
          .cont {
            padding: 0 300px 0 200px;
          }
          .left, .center, .right {
            position: relative;
            min-height: 130px;
            float: left;
          }
          .left {
            left: -200px;
            margin-left: -100%;
            background: green;
             200px;
          }
          .right {
            right:-300px;
            margin-left: -300px;
            background-color: red;
             300px;
          }
          .center {
            background-color: blue;
             100%;
          }
        </style>
      </head>
      <body>
        <div class="cont">
          <div class="center">中间</div>
          <div class="left">左边</div>
          <div class="right">右边</div>
        </div>
      </body>
      </html>

    Margin-right设置为整数 不会对自身元素造成影响 让平行元素往右移动

    Margin-right设置为负数 自身元素就会向右移动

  • 相关阅读:
    data:image/png;base64
    需要去了解的知识
    【转】react的高阶组件
    几个css问题
    antd中form中resetFields清空输入框
    react中map循环中key取值问题
    react中父组件调用子组件的方法
    hive 初始化 时间问题 The server time zone value 'EDT' is unrecognized
    centos7安装MySQL8 无法修改密码 无法修改密码策略
    虚拟机 Linux 不能连 xshell 不能上网
  • 原文地址:https://www.cnblogs.com/LXW2002326/p/11502593.html
Copyright © 2011-2022 走看看