CSS position: absolute screen resolution problem

前端 未结 4 1449
暖寄归人
暖寄归人 2020-12-30 07:40

CSS code:

top:45;
left:98;
float:right;
position:absolute;z-index:2;

I have done the above coding for a floating div when I wa

4条回答
  •  粉色の甜心
    2020-12-30 08:07

    Absolutely positioned elements are positioned according to either a relatively positioned ancestor or the window. It sounds like in your case, it's being positioned in the window.

    The way to fix this is to put your absolutely positioned

    inside a relative container. That way, as the window changes size, it will stay in the correct spot:

    This div will always be 98px from the left and 45px from the top of its parent .

提交回复
热议问题