zoukankan      html  css  js  c++  java
  • html-定位

    概述:

      

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            /*
                position 定位
                static 静态定位(没有定位),默认
                relative 相对定位,相对于正常位置(原来没定位之前的位置)进行定位,还要占据位置
                absolute 绝对定位,没有占据位置,使元素完全脱离文档流
                         没有定位父级,则相对于整个文档发生偏移
                         参考最近非static定位的父级进行定位
                fixed    固定定位,相对于浏览器窗口进行定位
                方向词
                    left
                    right
                    top
                    bottom
                z-index 规定定位的层级(默认0)
                    值:number 值越大层级越高
    
             */
            div{
                width: 100px;
                height: 100px;
                background: aqua;
                /*margin: 50px auto;*/
            }
            .box1{
                position: relative;
                top: 20px;
                background: aquamarine;
            }
        </style>
    </head>
    <body>
        <div class="box1"></div>
        <div class="box2"></div>
    </body>
    </html>

    绝对定位:

      

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            .box1{
                width: 100px;
                height: 100px;
                background: aqua;
                position: absolute;
                top: 100px;
                left: 50px;
            }
            .box2{
                width: 200px;
                height: 200px;
                background: antiquewhite;
                margin: auto;
                position: relative;
            }
            #box{
                width: 500px;
                height: 500px;
                background: black;
                margin: 50px auto;
                position: relative;
            }
        </style>
    </head>
    <body>
        <div id="box">
            <div class="box2">
                <div class="box1"></div>
            </div>
        </div>
    </body>
    </html>
  • 相关阅读:
    关于将so 打包入APK的问题
    求 在独立service 中 调用contentprovider的方法
    ndk 环境下 c版 md5
    请教大牛们一个问题
    编写 service 与导出 jar 时注意的问题
    引入已编译好的动态库
    PHP 日期格式说明
    Ocaml 插件
    【转】简单至极的 PHP 缓存类
    PHP mysqlnd cannot connect to MySQL 4.1+ using old authentication
  • 原文地址:https://www.cnblogs.com/cxhzy/p/10096029.html
Copyright © 2011-2022 走看看