Css盒子水平垂直居中? 南桥春雪君归处 2023-02-06 104 阅读1分钟 父盒子开启display:flex, 并设置 justify-content:center;align-items:center; 子绝父相,子盒子设置top和left值为50%,利用transform基于自身回去-50% 父盒子开启flex,子盒子设置margin:auto 子绝父相,子盒子设置定位上下左右均为0,在设置margin:auto也可以