Jquery-屏幕左上角的位置

Jquery - Position Top Left of Screen

本文关键字:位置 左上角 屏幕 Jquery-      更新时间:2023-09-26

I使用jQuery,无论屏幕分辨率如何,我都如何让这个子div位于屏幕的左上角?

<div style="position: relative; margin: auto; width: 500px">
    <div style="position: absolute;></div>
</div>

http://jsfiddle.net/Tmr4p/

该解决方案需要与IE兼容。

position:fixed
top:0;
left:0;

应该这样做

<div style="position: absolute; left: 0; top: 0;"></div>

如果您没有引用父分区,则修复此问题。

已检查IE和Chrome(暂时),示例

基于这条链的给定答案。