简体   繁体   English

JQuery灯箱插件:缩放非常大的图像以适应屏幕

[英]JQuery lightbox plugin: Scaling very large images to fit screen

I'm using the jQuery "Lightbox" plugin, although I don't know if that's necessary information about the problem at hand. 我正在使用jQuery “Lightbox”插件,虽然我不知道这是否是关于手头问题的必要信息。

The images I'm putting through my slideshow are quite large; 我通过幻灯片放映的图像非常大; each of them is far larger than the screen (I don't host the images on my server so I cannot resize them). 他们每个都比屏幕大得多(我没有在我的服务器上托管图像,所以我不能调整它们的大小)。 I need to scale them to fit within the bounds of the screen (probably with some margin as well). 我需要缩放它们以适应屏幕的范围(也可能有一些余量)。 Are there some JQuery or other Javascript snippets out there to take care of this? 是否有一些JQuery或其他Javascript片段来处理这个?

Edit 编辑

Now I use "zoombox", which certainly fixes the scaling issue. 现在我使用“zoombox”,这肯定解决了缩放问题。 However, now all the nice slideshow features are lost! 但是,现在所有漂亮的幻灯片功能都丢失了! Ie, I cannot use the arrow keys or cycle through the gallery of images! 即,我不能使用箭头键或循环图像库!

Here are three plugins which are pretty feature rich and widely used, they should do the job with ease : 这里有三个功能丰富且使用广泛的插件,它们应该可以轻松完成这项工作:

http://www.jacklmoore.com/colorbox http://www.jacklmoore.com/colorbox

http://fancybox.net/ http://fancybox.net/

http://www.grafikart.fr/zoombox http://www.grafikart.fr/zoombox

Edit: Pretty much every lightbox solution is listed and compared at : http://planetozh.com/projects/lightbox-clones/ 编辑:几乎每个灯箱解决方案都列出并进行了比较: http//planetozh.com/projects/lightbox-clones/

I've settled on Floatbox after testing out a dozen of these libraries. 在测试了十几个这样的库后,我已经确定了Floatbox The default settings size the image to fit the screen and allow navigation with the arrow keys. 默认设置可调整图像大小以适合屏幕,并允许使用箭头键进行导航。 Clicking on an image zooms it to 100%. 单击图像可将其缩放至100%。 It's easily configurable in terms of colors, window decorations, and the like. 它可以在颜色,窗口装饰等方面轻松配置。

I forked Lightbox2 to include automatic scaling. 我将Lightbox2分叉,包括自动缩放。

Now, if an image is larger than the window, it will automatically resize to 80%. 现在,如果图像大于窗口,它将自动调整为80%。

You can find it here , on my new repo. 你可以找到它在这里 ,我的新的回购协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM