• 02-CSS基础与进阶-day9_2018-09-12-20-29-40


    定位
    静态定位 position: static
    相对定位 position: relative
    绝对定位 position: absolute 脱标 参考点
    子绝父相
    让绝对定位的盒子水平居中和垂直居中
    固定定位 position: fixed
    参考点 浏览器左上角
    固定定位的元素脱标不占有位置
    兼容性 ie6低版本不支持固定定位

    02绝对定位的应用.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
            .fa {
                width: 600px;
                height: 300px;
                margin: 60px auto;
                background-color: skyblue;
                position: relative;
            }
               
            /*让儿子盒子水平居中*/   
            .son {
                width: 200px;
                height: 100px;
                background-color: pink;
                /* margin: 0 auto; 对绝对定位的盒子无效*/
                position: absolute;
                left: 50%; /*百分比参考父亲的宽度*/
                margin-left: -100px; /*自己的宽一半*/
                top: 50%;
                margin-top: -50px;
                /* left: 300px;
                top: 150px; */
            }
        </style>
    </head>
    <body>
        <div class="fa">
            <div class="son"></div>
        </div>
    </body>
    </html>
  • 相关阅读:
    HDU 4814 Golden Radio Base
    我对Swift的几点疑问
    【UTR #1】ydc的大树
    jsp中的隐含9对象
    动作元素
    指令元素
    JSP语法
    设计模式六大原则(6):开闭原则
    设计模式六大原则(5):迪米特法则
    设计模式六大原则(4):接口隔离原则
  • 原文地址:https://www.cnblogs.com/HiJackykun/p/11069711.html
Copyright © 2020-2023  润新知