• 自适应布局 左右结构、上下结构


    一、左右结构   左边固定,右边自适应

    1. 左边左浮动,右边加个overflow:hidden;

       #lt{ float: left;200px; background: #ff0;}
    
       #rt{ overflow: hidden; background: #f0f;}

    2. 左边左浮动,右边加个margin-left;

       #lt{ float: left; 200px; background: #ff0;}
    
       #rt{ margin-left: 200px; background: #f0f;}

    3. 左边绝对定位,右边加个margin-left;

       #lt{ position: absolute; top:0; left:0; 200px; background: #ff0;}
    
       #rt{ margin-left: 200px; background: #f0f;}

    4. 左右两边绝对定位,右边加个width,top,left,right

     #lt{ position: absolute; top:0 ; left:0 ;200px; background: #ff0;}
    
     #rt{ position: absolute; top:0 ; left:200px;  100% ; rigth:0;background: #f0f;}

    二、左右结构 右边固定,左边自适应的布局

    1. 左边左浮动,margin-left负值,右边右浮动;

    #lt{float:left; 100%;background: #00f;margin-right: -200px;}
    #rt{float: right;  200px;background: #ff0;}

    2. 右边绝对定位,左边margin-right;

       #lt{margin-right:200px; background: #00f;}
    
       #rt{ position: absolute; right:0; top:0;  200px;background: #ff0;}

    3. 左右两边绝对定位,左边加个width,top,left,right

       #lt{ position: absolute; top:0; left:0; rigth:0;  100% ; background: #f0f;}
    
       #rt{ position: absolute; top:0; left:200px; 200px; background: #ff0;}

    三、上下结构自适应

     .header,.footer{
           100%;
          height: 100px;
          line-height: 100px;
          background-color: red;
     }
    .content{
            100%;
            position: absolute;
             top: 100px;
             bottom:100px;
              background-color: yellow;
    }
    .footer{
        position: absolute;
        bottom: 0px;
    }
    
        <div class="header">头部</div>
        <div class="content">内容</div>
        <div class="footer">底部</div>            
  • 相关阅读:
    js 图片转base64上传图片
    小程序 分享之后,从分享点进去 input里面中文值被转化成字符,需再转化成中文方法
    uni-app map组件的marker
    Python小练习003
    Python小练习002
    Python小练习001
    耶鲁大学——心理学导论(这就是你的大脑)
    ORACLE 创建新表
    键盘事件
    VIDEO当前视频的总长度和视频进度
  • 原文地址:https://www.cnblogs.com/SPHmomo/p/7531392.html
Copyright © 2020-2023  润新知