定位

作者: neko233 | 来源:发表于2018-09-12 10:19 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style type="text/css">
            .box1{
                background-color: red;
                width: 200px;
                height: 200px;
            }
            .box2{
                background-color: yellow;
                width: 200px;
                height: 200px;
                /*相对定位,相对于原来位置定位*/
                /*position: relative;*/
                /*绝对定位 脱离文档轴 原点为最近的开启定位的祖先元素原点*/
                /*position: absolute;*/
                /*固定定位 脱离文档轴 根据浏览器窗口定位*/
                position: absolute;
                left: 200px;
                top: 200px;
            }
            .box3{
                background-color: green;
                width: 200px;
                height: 200px;
            }
            .s1{
                width: 200px;
                height: 200px;
                background-color: yellow;
            }
        </style>
    </head>
    <body>
        <!-- div.box$*3 -->
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
        <span class="s1">span</span>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:定位

          本文链接:https://www.haomeiwen.com/subject/wewmgftx.html