• 高度自适应,内容是浮动元素


    可以有四种方法:

    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>
  • 相关阅读:
    String类的concat()方法
    字符串转换为时间类型
    translate函数
    弹出窗口
    数据库大小写问题
    360浏览器屏蔽广告
    String.valueOf()
    测试
    选择排序算法
    输出101~200内的质数
  • 原文地址:https://www.cnblogs.com/rachelch/p/7497888.html
Copyright © 2020-2023  润新知