首页 > 其他 > 详细

div水平垂直居中

时间:2020-06-20 14:50:23      阅读:65      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body,
        html {
            margin: 0;
            width: 100%;
            height: 100%;
        }

        #box {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            position: relative;
        }

        #content {
            position: absolute;
            width: 70%;
            height: 70%;
            background: pink;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
            -ms-transform: translateX(-50%) translateY(-50%);
            -webkit-transform: translateX(-50%) translateY(-50%);
        }
    </style>
</head>

<body>
    <div id="box">
        <div id="content"></div>
    </div>
</body>

</html>

  

div水平垂直居中

原文:https://www.cnblogs.com/dog2016/p/13168534.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!