给浮动元素套一个父盒子与之大小一致然后使用绝对定位使其垂直居中
<style>.fl {float: left; width: 100px; height: 100px; border: 1px solid #000;}.father {width: 100px; height: 100px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);}</style><div class="father"><div class="fl"></div></div>


