如何垂直居中一个浮动元素? 情况一:知道父元素的宽和高 /*父元素.box 要添加了绝对定位*/ .box div{ position: absolute; width: 50px; height: 50px; top: 50%; left: 50%;/*走父元素高度和宽度的一半*/