盒子水平垂直居中

分类:CSS | 标签: 垂直居中  
2021-12-06 11:03 阅读(?)评论(0)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <style>
        html,body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    
        body {
            display: flex;
            align-items: center; /*定义body的元素垂直居中*/
            justify-content: center; /*定义body的里的元素水平居中*/
        }
        .content {
            width: 300px;
            height: 300px;
            background: orange;        
        }
    </style>
</head>
<body>
    <div class="content"></div>
</body>
</html>
  最后修改于 2021-12-06 11:27    阅读(?)评论(0)
 
表  情:
加载中...
 

请各位遵纪守法并注意语言文明