抱歉,我在下面的原始问题中可能不清楚...
我正在寻找的是一种让弹出窗口在窗口可视区域内移动的方法(而不是实际创建弹出窗口本身)。正如在谷歌图像中看到的那样,当你将鼠标悬停在屏幕边缘的图像上时,不知何故(这是我想知道的),脚本检测到没有足够的空间让弹出窗口出现在窗口中,所以它推送它可视范围内。
所以我想知道这是如何确定和计算的。
How can I use javascript to make sure a popup div fits inside the window when it appears?
A good example is google's image search. When a image does not fit in the window (either it is the far right most or bottom most image), somehow it is pushed inside when the popup is opened with the mouseover event. How is this calculated and how can I create a script to calculate this.
最佳答案
你可以使用已经构建的弹出框/覆盖窗口js库。使用 jQuery js 框架并选择任何提供相同功能的插件。我推荐你使用facybox http://fancybox.net/使用 jQuery,这让这一切变得非常简单。
关于javascript - 在屏幕上安装绝对 div 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5441342/