zoukankan      html  css  js  c++  java
  • 「HTML+CSS」五环居中,两栏布局,经典bug,BFC

    *{
        margin: 0px;
        padding: 0px;
    }
    .frame{
        position: fixed;
        left:50%;
        top:50%;
        margin-left: -200px;
        margin-top: -85px;
        400px;
       height: 170px;
       border: 1px solid black;
    }
    .cir1,
    .cir2,
    .cir3,
    .cir4,
    .cir5{
        position: absolute; 
         100px;
        height: 100px;
        border: 10px solid black;
        border-radius: 50%;
    }
    .cir1{
        border-color: black;
        top: 0;
        left: 0;
    }
    .cir2{
        border-color: blue;
        left: 140px;
        top: 0;
    }
    .cir3{
        border-color: yellow;
        left: 280px;
        top: 0;
    }
    .cir4{
        border-color: red;
        left: 70px;
        top: 50;
    }
    .cir5{
        border-color: #f40;
        left: 210px;
        top: 50;
    }


    div{
        position: fixed;
         50px;
        height: 100px;
        background-color: red;
        left: 0px;
        bottom: 100px;

    }

     

     两栏布局:  本质就是变成层级结构,使下面的元素浮动到上面去

    magin-left:100px即可

     


     magin塌陷和magin合并BFC

         垂直向上的magin父子元素取决于最大的值如:

        

     margin-right: 50px;

     

    父子元素,若想要子相对于父往下走,可是没有margin相当于父上面没有棚,边界

     不推荐用

     BFC-block format content 块级格式化上下文

       通过css手段让其渲染规则发生改变

    特定的盒子会遵循另一个语法规则

      

     

     都能弥补margin塌陷


     Margin合并

     为什么会有空格:文本分隔符,

     

     区域不能共用

    margin-right:xxpx;

     margin-left:xxpx;

     

     

     

    原因,两个垂直方向的元素,margin是样的,你上面要空出bottom100px按理说下面的元素也要空出top100px,而下面的无动于衷,这怎么解决呢?很简单那上面多家像素即可;


     

     

     如:

     

       

  • 相关阅读:
    定义 : angular view 和controller 之前的 ng-init 由谁来负责
    pl/sql如何在云端服务器上新建数据库
    oracle连接服务器上数据库
    svn check下来的代码在eclipse中没有run on server
    sql server在修改表结构后不能保存
    用mybatis-generator自动生成代码报“前言中不允许有内容”
    启动Tomact时报failed to start conponent
    spring MVC中controller失效
    maven项目中连接sqlserver和mysql的区别
    DBCP连接池的配置
  • 原文地址:https://www.cnblogs.com/apelles/p/11630247.html
Copyright © 2011-2022 走看看