zoukankan      html  css  js  c++  java
  • 高度自适应,内容是浮动元素

    可以有四种方法:

    1.添加overflow:hidden;

    2.添加伪元素

    //方法2
    <style>
      .wrap{
        border:1px solid blue;
        600px;
        margin:0 auto;
        padding:20px 0;
      }
      .main{
        float:left;
        background:pink;
        350px;
        height:100px;
      }
      .side{
        float:left;
        background:rosybrown;
        200px;
        height:100px;
      }
      .wrap:after{
        content:'';
        display:block;
        clear:both;
      }
      .wrap{
        zoom:1;//触发IE的hasLayout属性,该属性IE独有
      }
    </style> <div class="wrap">   <div class="main"></div>   <div class="side"></div> </div>

     3.父元素设置为浮动

    4.添加空元素

      直接在浮动的子元素下添加一个非浮动的空元素

    <div style="border:5px solid #000;">
        <div style="float:left;45%;height:100px;background:#ccc"></div>
        <div style="float:right;45%;height:100px;background:#000"></div>
        <div style="clear:both"></div>
    </div>
  • 相关阅读:
    二叉树的层序遍历-102
    剑指offer 06 从尾到头打印链表
    替换空格:剑指offer05
    面试题16.11.跳水板----leetcode
    JVM——垃圾回收
    新生代Eden与两个Survivor区的解释
    JVM 1.8 永久代---元空间 的变动
    Git拉取项目避坑
    python-装饰器
    python-Queue
  • 原文地址:https://www.cnblogs.com/rachelch/p/7497888.html
Copyright © 2011-2022 走看看