position之absolute居中定位
.parent { position: relative; width: 200px; height: 150px; background: blue; } .child { position: absolute; width: 80px; height: 80px; background: red; top: 0; bottom: 0; left: 0; right: 0; margin: auto auto; } <div class="parent"> <div class="child"></div> </div>
略懂,略懂....