• 学习微信小程序之css18绝对定位


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>绝对定位</title>
        <style>
         *{
             margin: 0;
             padding: 0;
         }
           .header,.wrap,.close{
               background-color: teal;
               border: 1px solid #000000;
           }
            .header{
                height: 200px;
            }
            .wrap{
                background-color: #0099cc;
                 400px;
                /*父元素相对定位*/
                position: relative;
            }
           .close{
               height: 20px;
                20px;
               /*使用 position: absolute;需要父元素是相对定位*/
               /* position: absolute; 绝对定位*/
               position: absolute;
               top: 0;
               right: 0;
           }
        </style>
    </head>
    <body>
    <div class="header">
        head
    </div>
    <div class="wrap">
        <div class="txt">
            adfjak
        </div>
        <div class="main">
            mainsahgfdkjsxvsdjklfhas
        </div>
        <div class="close">
            x
        </div>
    
    </div>
    </body>
    </html>

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>绝对定位2</title>
        <style>
            .banner{
                 400px;
                margin: 0 auto;
                background-color: teal;
                height: 400px;
                /*父元素相对定位*/
                position: relative;
            }
    
            .slide-1,.slide-2{
                background-color: yellow;
                height: 60px;
                 40px;;
                border: 1 solid #000000;
                color: black;
                /*绝对定位*/
                position: absolute;
                /*离上面一半距离*/
                top: 50%;
                /*上边距见25,即高度的一半,达到高度居中的效果*/
                margin-top: -30px;
    
            }
           .slide-1{
               left: 0;
           }
            .slide-2{
                right: 0;
            }
    
        </style>
    </head>
    <body>
    <div class="banner">
        banner
        <div class="slide-1">
            slide1
        </div>
        <div class="slide-2">
            slide2
        </div>
    </div>
    </body>
    </html>

  • 相关阅读:
    MxNet Windows下安装
    Binary Tree Postorder Traversal--leetcode难题讲解系列
    Populating Next Right Pointers in Each Node II--leetcode难题讲解系列
    Recover Binary Search Tree--leetcode难题讲解
    bash + script
    Linux笔记
    谷歌面经 Tree Serialization
    Python strange questions list
    bit操作 转
    ubuntu系统从中文环境改成英文环境
  • 原文地址:https://www.cnblogs.com/hywbk/p/6279374.html
Copyright © 2020-2023  润新知