代码之家  ›  专栏  ›  技术社区  ›  Etienne

SimpleLightbox jQuery插件提供了重新调整图像大小的功能?

  •  0
  • Etienne  · 技术社区  · 14 年前

    ( As seen here ).

    但这对我来说并没有发生,因为当我看到一个大图像时,它占据了整个页面,你必须滚动才能看到图像。

    在jquery文件或CSS中,是否缺少可以设置图像最大宽度和高度的内容?

    提前谢谢!

    1 回复  |  直到 14 年前
        1
  •  0
  •   netadictos    14 年前

    原则上,你不应该有这个问题。

    http://github.com/balupton/jquery-lightbox/blob/master/scripts/jquery.lightbox.js

     if ( this.auto_resize !== false )
    { // We want to auto resize
    var maxWidth = Math.floor(wWidth*(4/5));
    var maxHeight = Math.floor(wHeight*(4/5));
    var resizeRatio;
    while ( iWidth > maxWidth || iHeight > maxHeight )
    { // We need to resize
    if ( iWidth > maxWidth )
    { // Resize width, then height proportionally
    resizeRatio = maxWidth/iWidth;
    iWidth = maxWidth;
    iHeight = Math.floor(iHeight*resizeRatio);
    }
    if ( iHeight > maxHeight )
    { // Resize height, then width proportionally
    resizeRatio = maxHeight/iHeight;
    iHeight = maxHeight;
    iWidth = Math.floor(iWidth*resizeRatio);
    }
    }
    }
    

    这里有iWidth,它是图像宽度,maxWidth是屏幕宽度。

    如果iWidth较大,则等于maxWidth。

    一定有用。