一个盒子垂直水平居中的方法

it2023-02-22  82

flex方法

display:flex; justify-content:center; align-item:center;

定位

首先子绝父相,然后子级盒子的top:50%;left:50%;tranform:translate(-50%,-50%);

margin

margin:0 auto;(这个只能设置水平上的居中(补))

最新回复(0)