zoukankan      html  css  js  c++  java
  • position

    html的三种布局方式:

    • 标准流(默认,顺序布局)
    • 浮动
    • 定位

    两大元素

    • 块级元素(div,table,h1~h6,ul,li,p...)  独占一行
    • 内联元素(a,span,img,input) 和相邻内联元素在同一行,一行宽度不够会重起一行

    position:relative:对宽高无影响

      left:10px top:10px 向右移动10px,向下移动10px

      right:10px bottom:10px 向左移动10px,向上移动10px

    position:absolute(脱离正常的文档流):此时元素b高度为0,没有设置left,top,right,bottom(

    若此时有一个非absolute的元素a,则按照标准流先排列a,再排列b

    若此时给元素b设置了left,top等属性,也是先排列a,再排列b,b有可能覆盖a


     .test{
                position: absolute;
                100px;
                height: 100px;
                background: red;
            }
            .parent{
                200px;
                height: 200px;
                background: blue;
                margin-top:200px;
                margin-left:200px;
            }
    
    <div class="parent">
        <div class="test">
        </div>
    </div>

     .test{
                position: absolute;
                100px;
                height: 100px;
                background: red;
                left:0;
                top:0;
            }
            .parent{
                200px;
                height: 200px;
                background: blue;
                margin-top:200px;
                margin-left:200px;
            }

    .test{
                position: absolute;
                100px;
                height: 100px;
                background: red;
                left:0;
                top:0;
            }
            .parent{
                200px;
                height: 200px;
                background: blue;
                margin-top:200px;
                margin-left:200px;
                position: relative;
            }

    position:fixed

      不受制于父元素,即使父元素有定位。固定在屏幕的某个地方,不会随任何元素而移动 

  • 相关阅读:
    HTTP 无法注册 URL http://+:xxxxx/ServicesName/。进程不具有此命名空间的访问权限
    C语言中宏的一些特别用法
    static和const的比较和解释
    堆和栈的区别
    c++中const用法
    链表常见笔试题
    自绘实现半透明水晶按钮 .
    C++面试题
    C/C++面试题大汇总
    C++ 值传递、指针传递、引用传递详解
  • 原文地址:https://www.cnblogs.com/yintingting/p/8747826.html
Copyright © 2011-2022 走看看