jquery - Custom width and height on fancybox image -


i wonder if posible set custom width , height on fancybox images?

as standard, width , height of fancybox changes in relative width , height of images, want 800 width , 600 height, @ images.

i want create familiar image-box on facebook, see image @ left, , description , comments @ right.

could great if me this... :)

  • theyaxxe

a simpler way change size of both, fancybox opened image , fancybox parent container using beforeshow callback :

$(".fancybox").fancybox({     fittoview: false, // avoids scaling image fit in viewport     beforeshow: function () {         // set size (fancybox) img         $(".fancybox-image").css({             "width": 800,             "height": 600         });         // set size parent container         this.width = 800;         this.height = 600;     } }); 

see jsfiddle

note : fancybox v2.x+


edit (april 2014) :

with current version of fancybox (v2.1.5 today), it's not necessary apply css rules .fancybox-image selector since images set responsive (max-width: 100%;). this.width , this.height alone trick

$(".fancybox").fancybox({     fittoview: false,     beforeshow: function () {         this.width = 800;         this.height = 600;     } }); 

see forked jsfiddle


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -