Loading...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <style>
        html,body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        .content {
            width: 300px;
            height: 300px;
            background: orange;
            margin: 0 auto; /*水平居中*/
            position: relative;
            top: 50%; /*偏移*/
            transform: translateY(-50%);
        }
    </style>
</head>
<body>
    <div class="content"></div>
</body>
</html>
版权所有©转载必须以链接形式注明作者和原始出处:江湖源码 » CSS3实现垂直居中的方法

: http://www.jhcms.net/index.php/2020/12/04/css3%e5%ae%9e%e7%8e%b0%e5%9e%82%e7%9b%b4%e5%b1%85%e4%b8%ad%e7%9a%84%e6%96%b9%e6%b3%95/

No comments yet.