• transform: translate(-50%, -50%) 实现块元素百分比下居中


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>position & transform: translate(-50%, -50%) 实现块元素百分比下居中</title>
    <style>
    html,body {
            width: 100%;
            height: 100%;
            position: relative;
        }
        .box {
            width: 800px;
            height: 500px;
            background-color: #FFD914; 
        }
        .inside {
            width: 60%;
            height: 30%;
            background-color: red;
        }
        .center { 
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
    </head>
    <body>
        <div class="box center">
            <div class="inside center"></div>
        </div>
    </body>
    </html>
  • 相关阅读:
    Spring aop 实现异常拦截
    drf 视图家族
    算法与数据结构
    接口
    Kubernetes
    drf
    drf 序列化
    drf 内部模块
    drf 接口
    vue
  • 原文地址:https://www.cnblogs.com/hjbky/p/6484639.html
Copyright © 2020-2023  润新知