最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I resize images in Lightbox2? - Stack Overflow

programmeradmin5浏览0评论

I'm using /. I have image thumbnails and on clicking them they open in lightbox - obviously.

The issue I have is that when some of those images are 1800x1200, lightbox covers the whole webpage.

How can I edit to ensure that the images are a maximum height of let's say 400px and width is in proportion? I can't simply upload the images in lower dimensions as they are user uploaded images, so I need to do this script/server side.

Thanks!

I'm using http://lokeshdhakar./projects/lightbox2/. I have image thumbnails and on clicking them they open in lightbox - obviously.

The issue I have is that when some of those images are 1800x1200, lightbox covers the whole webpage.

How can I edit to ensure that the images are a maximum height of let's say 400px and width is in proportion? I can't simply upload the images in lower dimensions as they are user uploaded images, so I need to do this script/server side.

Thanks!

Share Improve this question asked Oct 30, 2012 at 2:42 DaveDave 6872 gold badges11 silver badges26 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

You can use the max-width and max-height CSS properties on both the images and the lightbox:

Demo: http://jsfiddle/rdfAV/1/

CSS:

img {
    max-width: 400px;
    max-height: 400px;
}

.lb-outerContainer, .lb-dataContainer {
    max-width: 420px;
    width: auto!important;
    height: auto!important;
}​

This method appears to be patible with all major browsers, a full patibility list is available here: http://caniuse./#feat=minmaxwh

Please try adding the following to your CSS:

 .lb-image{
      max-width: inherit;
  }

Thanks A Lot .. Really Help Full To My Landing Page

Some Editied Code , Play Wisely

img {
max-width: 800px;
max-height: 600px;
}

.lb-outerContainer, .lb-dataContainer {
max-width: 800px;
width: auto!important;
height: auto!important;
}​
发布评论

评论列表(0)

  1. 暂无评论