zoukankan      html  css  js  c++  java
  • 清除浮动

    <div class="outer">
        <div class="div1">1</div>
        <div class="div2">2</div>
        <div class="div3">3</div>
    </div>
    .outer{border: 1px solid #ccc;background: #fc9;}
    .div1{width: 80px;height: 80px;background: red;float: left;}
    .div2{width: 80px;height: 80px;background: blue;float: left;}
    .div3{width: 80px;height: 80px;background: sienna;float: left;}

    效果:子元素浮动,父元素未规定宽高,(1):背景不能显示 (2):边框不能撑开 (3):margin 设置值不能正确显示

    清除浮动:

    1. 增加一个块级元素,然后clear:both 设置height,line-height

    • html中outer div里添加<div class="clear"></div>
    • css添加:.clear{clear:both; height: 0; line-height: 0; font-size: 0}

    2. 父元素设置css overflow:auto;zoom:1;

    3. 通过beforeafer在元素内部插入块元素 content:"";diplay:block;height:0;0;clear:both;

  • 相关阅读:
    servicestack and redis
    图片服务器
    CRQS介绍
    javascript闭包之购物车加减及提示
    javascript best practices
    EOF
    2012年回顾
    volatile
    通过inode来操作文件
    采样问题
  • 原文地址:https://www.cnblogs.com/danranysy/p/4776634.html
Copyright © 2011-2022 走看看