[转]position:relative leaves an empty space

本文转自:http://stackoverflow.com/questions/5229081/positionrelative-leaves-an-empty-space

在使用relative进行定位时

比如一个设置了width的td内 包含select 和 input

将input通过position:relative ; top:-23px 进行位置上移  覆盖了select的部分区域

但td的高度 却还是两个控件的高度

可以通过margin-bottom的设置 来使其空白不占高度

Another trick which worked fine for me is to use a negative margin-bottom in the relative element that you have moved. No need to go with absolute positioning.

Something like:

position: relative;
left:100px
top:-200px;
margin-bottom:-200px;

Similar (if not identical) to the solution I see now, from green.

原文地址:https://www.cnblogs.com/freeliver54/p/3534637.html