[转]position:relative leaves an empty space

本文转自:http://*.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.

[转]position:relative leaves an empty space

上一篇:cnblog可以直接黏贴qq截图,但最好不要偷懒


下一篇:iOS申请真机调试证书-图文详解