设为首页 加入收藏

TOP

关于盒子的水平垂直居中几种方案
2019-09-03 03:42:58 】 浏览:45
Tags:关于 盒子 水平 垂直 居中 方案

HTML

<div class='father'>
    <div class='child'></div>
</div>

CSS

第一种

    .father {
        display: table-cell;
        text-align: center;
        vertical-align: middle;
    }
    
    .child {
        display: inline-block;
    }

第二种

    .father {
        position: relative;
    }
    
    .child {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

第三种

    .father {
        display: flex;
        justfy-content: center;
        align-items: center;
    }
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇js — 基础知识 下一篇条件注释的两种形式——下层隐藏..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目