我正在使用名为 jb gallery 3.0 的图像 slider - 使用 jQuery 运行。
它只是一个普通的图像 slider ,但它具有检测浏览器大小然后将图像缩放到浏览器大小的功能,即。如果您在 iPad 上查看,它会给您一个较小的图像,以便您仍然可以看到整个图片。
每次在 slider 中加载图像时都会调整大小,因此如果您在幻灯片之间调整窗口大小,则下次加载图像时它将被缩放...无需刷新页面。
这一切在 safari 和 chrome 中都可以正常工作,但在 firefox 和 opera (12.14) 中却不行,它只提供裁剪后的全尺寸图像...
我对这里发生的事情做了一个 js fiddle - http://jsfiddle.net/ktvvW/5/ - 尝试调整 chrome 或 safari 中“结果”面板的大小,看看会发生什么。
知道为什么这在 ff 或 opera 中不起作用吗?
.
干杯
最佳答案
在 jbgallery-3.0.js 脚本上强制执行 webkit 行为似乎可以解决这个问题。 请参阅下面的选项,我强制 webkit 为 true(忽略 userAgent)。 我已经在 FF 和 Opera 上对此进行了测试,功能符合预期,图像以与 Chrome 中相同的缩放比例显示。
$(".jbgallery").jbgallery({
style : "zoom", //"centered"|"zoom"|"original" - image style
menu : "simple", //false|"numbers"|"simple"|"slider" - menu type
shortcuts: [37, 39], //[prev,next] - keyboard code shortcuts
slideshow: true, //true|false - autostart slideshow
fade : true, //true|false - disable all fade effects
popup : false, //true|false - modal box & traditional popup hack to display multiple gallery (3.0 : fullscreen:false)
randomize: 0, //0|1|2 - randomize first image (1) or randomize "slideshow" (2) - blackout: http://www.grayhats.org
caption : false, //true|false - show/disable internal caption system
autohide : false, //true|false - auto hide menu & caption
clickable: false, //true|false - "image click & go"
current : 1, //number - set initial photo (modal "hack" - see demo. don't use "hash". jbgallery use "location.hash" only in popup mode)
// webkit : (navigator.userAgent.toLowerCase().search(/webkit/) != -1), //boolean - used for specific browser hack. if you want, you can force disable this flag & try to find crossbrowser solution
webkit : true,
ie6 : (/MSIE 6/i.test(navigator.userAgent)), //boolean - IDEM
ie7 : (/MSIE 7/i.test(navigator.userAgent)), //boolean - IDEM
labels : { //labels of internal menu
play : "play",
next : "next",
prev : "prev",
stop : "stop",
close: "close",
info : "info"
},
timers : { //timers
fade : 1000, //fade duration
interval: 3000, //slideshow interval
autohide: 7000 //autohide timeout
},
delays: { //delays (timers) to improve usability and reduce events
mousemove: 200, //used by autohide. cancel autohide timeout every XXXms.
resize : 10, //used by ie6 to reduce events handled by window.resize
mouseover: 800 //used by tooltip. show tooltip only if the mouse STAY over thumb for XXXms
},
close : function(){}, //callback handled by menu's button close. see demo. example : close : function(){window.close()}
before : function(){}, //callback handled BEFORE image gallery loaded
after : function(ev){}, //callback(ev) handled AFTER image gallery loaded. receive the native load event.
load : function(ev){}, //callback(ev) handled AFTER native image load event. receive the native load event.
ready : function(el){$('.jbg-menu').hide(); $('.jbg-loading').remove(); $('.jbg-caption').remove(); $('.jbg-menu-opacity').remove();}, //callback(el) handled AFTER jbgallery render. receive the HTML element.
fullscreen: false, //true|false : the most important feature of jbgallery 3.0. now jbgallery can "stay in a box" and have multiple istance in one page.
push : function(o){}, //callback handled by push public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external. useful for external menu system
unshift : function(o){}, //callback handled by unshift public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external.
shift : function(){}, //callback handled by shift public method
pop : function(){}, //callback handled by pop public method
empty : function(){} //callback handled by empty public method
});
关于javascript - 图像在 safari 和 chrome 中缩放,但在 ff 和 opera 中不缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15070107/