【CSS】使用position定位实现水平垂直居中

188 阅读1分钟

使用子绝父相定位:

1、给需要水平垂直居中的子元素设置:

position: absolute;    
top: 50%;    
left: 50%;    
transform: translate(-50%,-50%);

2、给该元素的父元素设置:

position:relative


.....待添加