2

Fancybox を介して画像をウィンドウに完全に引き伸ばすにはどうすればよいですか? (Fancybox 2) ファンシーボックスは画像サイズと同じ大きさに伸びますが、それ以上は伸びません。

ファンシーボックス css には、次のような多くの CSS 制限が残っていることに気付きました。

.fancybox-image, .fancybox-iframe {
    display: block;
    width: 100%;
    height: 100%;
}

.fancybox-image {
    max-width: 100%;
    max-height: 100%;
}

取り出しmax-width/heightて設定すると、画像が引き伸ばさwidth/height200%ますが、含まれる長方形自体 (つまり、fancybox) は同じサイズであり、中央に配置されなくなります。

私はインラインメソッドを使用しています:jQuery(".fancybox").fancybox()

4

1 に答える 1

3

i-pretty-much-gives-up-except-for-some-cool-but-useless-stuff アプローチ:

.fancybox({
 afterLoad  : function () {
  function gcd (x, y) {while (y != 0) {var z = x % y; x = y; y = z;} return x}
  var body = $(document.body)
  if (this.width/this.height > 1) {
   // Max size is document body width.
   var body_width = body.width()
   var current_multiplier = gcd (this.width, body_width)
   if (current_multiplier == 1) current_multiplier = body_width
  } else {
   // Max size is document body height.
   var body_height = body.height()
   var current_multiplier = gcd (this.height, body_height)
   if (current_multiplier == 1) current_multiplier = body_height
  }
  this.width  = this.width  * current_multiplier
  this.height = this.height * current_multiplier
 }
})
于 2013-01-31T00:36:43.960 に答える