首先父元素確定是要相對定位的,其次咱們上下左右居中的元素的css以下:css
width: 50px; height: 50px; margin: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0;