I am using lightbox 2 to show in enlarge of images, some picture size are bigger than to browser window size and difficulty to see, so how to fix the lightbox image box size to default?
Asked
Active
Viewed 1.1k times
2
-
1I don't remember a specific name right now, but there are other lightbox products that do an auto-resize in such a case. Google `lightbox alternatives` – Pekka Dec 24 '11 at 12:09
1 Answers
3
Maybe you can use CSS. Something like:
#lightbox #imageContainer img {
max-width: 600px;
}
/*********************************************
*
* NOTE: "max-width" is not supported by IE6.
* If al your images are bigger than
* the "default", just use "width".
*
*********************************************/
I would recommend using another lightbox library. My favorite is Colorbox, it actually has an option named scalePhotos
, which according to their description:
If true, and if maxWidth, maxHeight, innerWidth, innerHeight, width, or height have been defined, ColorBox will scale photos to fit within the those values.
This option is true
by default.

Ayman Safadi
- 11,502
- 1
- 27
- 41
-
-
@Rembo, your .net/ASP code is irrelevant. Please post your HTML instead. In any case, here's a working example of a 1024x1024 image contained in a 200px Colorbox. http://jsfiddle.net/mzjKx/1/ – Ayman Safadi Dec 24 '11 at 19:49
-
i want to use colorbox in asp.net 3.5, on my above code when i click in tag image opens on same page but not in colorbox. – Abhishek Nayak Dec 24 '11 at 20:12
-
1@Rembo. Colorbox (or any other lightbox plugin for that mater)... strike that... **JavaScript** does not interact with .NET, ASP, PHP, Python, RoR, Pearl, Java or any other back-end scripting language. JavaScript interacts with HTML. If you can't understand that, I can't help you any further. – Ayman Safadi Dec 24 '11 at 20:50
-
Colorbox is still relevant in 2015. Serious network interference is making it very hard to edit remotely. I was fighting LB2's behavior, and its git comments say get support on SO, but here people guessed at setting .classes and maybe there are docs. With seconds between keypresses, I had to switch: Colorbox worked immediately. Thanks. – ǝɲǝɲbρɯͽ Mar 11 '15 at 23:38