zoukankan      html  css  js  c++  java
  • 等高布局

    等高布局可以使用display:table-cell或者padding与margin对冲两种方法。可以在IE8+使用table-cell,低于IE8使用对冲。

    对冲原理
    将padding-bottom设置很大,来增加子容器高度,margin-bottom设为padding-bottom相等的负值来恢复子容器高度,
    父容器设置overflow:hidden来隐藏子元素。最后,使用内部div相对父容器绝对定位来模拟子容器的底边框。

    <div class="container">
         <div class="column left">
               <div class="btLine leftLine"></div>
         </div>
         <div class="column main" style="height: 800px;">
               <div class="btLine mainLine"></div>
         </div>
         <div class="column right">
               <div class="btLine rightLine"></div>
         </div>
    </div>
    <style>
    .container{width:970px;margin:0 auto;position:relative;
    display:table-row;overflow:hidden;}
    .column{display:table-cell;*margin-bottom:-3000px;*float:left;*padding-bottom:3000px;height:500px;}
    .left{width:300px;background:#7bd;border:1px solid green;}
    .main{width:500px;background:#e5e5e5;border:1px solid red;}
    .right{width:160px;background:#f63;border:1px solid blue;}
    .btLine{position:absolute;bottom:0;height:1px;}
    .leftLine{background:green;left:0;width:300px;}
    .mainLine{background:red;left:300px;width:500px;}
    .rightLine{background:blue;right:0;width:160px;}
    </style>
  • 相关阅读:
    《构建之法》阅读笔记二
    《构建之法》阅读笔记一
    软件工程个人课程总结
    纯随机数生成器
    递归方法
    素数的输出
    字母统计|英语的26 个字母在一本小说中是如何分布的
    类的声明
    FileInputStream类与FileOutputStream类
    验证码|程序登录界面
  • 原文地址:https://www.cnblogs.com/mengff/p/5227730.html
Copyright © 2011-2022 走看看