CSS位置:绝对屏幕分辨率问题 [英] CSS position: absolute screen resolution problem
本文介绍了CSS位置:绝对屏幕分辨率问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CSS代码:
top:45;
left:98;
float:right;
position:absolute;z-index:2;
我已经为浮动 div
当我在1024分辨率上工作,但是当我在不同的分辨率下测试相同的是不一致。
I have done the above coding for a floating div
when I was working on 1024 resolution, but when I tested the same on a different resolution it's out of alignment.
我们如何解决它?
How can we fix it?
推荐答案
绝对定位的元素根据相对定位的祖先或窗口定位。
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.
解决这个问题的方法是把你绝对定位的< div>
在相关容器内。这样,当窗口改变大小时,它将保持在正确的位置:
The way to fix this is to put your absolutely positioned <div>
inside a relative container. That way, as the window changes size, it will stay in the correct spot:
<div style="position: relative">
<div style="position: absolute; left: 98px; top: 45px;">
This div will always be 98px from the left and 45px from the top of its parent .
</div>
</div>
这篇关于CSS位置:绝对屏幕分辨率问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文