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>
  • 相关阅读:
    P1019 单词接龙
    最小生成树模板题POJ
    区间DP
    牛客多校第三场-A-PACM Team-多维背包的01变种
    洛谷P1004 方格取数-四维DP
    牛客多校第二场A run(基础DP)
    P1494 [国家集训队]小Z的袜子(莫队)
    洛谷:过河卒
    Codeforces Round #486 (Div. 3)-B. Substrings Sort
    判断的值是否为空
  • 原文地址:https://www.cnblogs.com/cxhzy/p/10096029.html
Copyright © 2011-2022 走看看