colorboxを使っているとレスポンシブの時に画像サイズが合わない事があります。
アンドロイド端末でオーバーレイが表示されない等の不具合もあります。
少し解析してみます。
Colorboxの調整は、CSSとJAVASCRIPTの両方で行えます。
関係ありそうなところ
#cboxOverlay{position:fixed; width:100%; height:100%;} #cboxLoadedContent{overflow:auto;} #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} .cboxPhoto{float:left; margin:auto; border:0; display:block;} .cboxIframe{width:100%; height:100%; display:block; border:0;}
バージョンによって微妙に違うんですが、基本はOverlayを増やして、画像のサイズを少し小さめにすると
それっぽく表示されるようになります。
スタイルを触らなくても、javascriptでパラメータ指定でも対応可能です。
デフォルトのパラメータが以下のように指定されているので
defaults = { // data sources html: false, photo: false, iframe: false, inline: false, // behavior and appearance transition: "elastic", speed: 300, fadeOut: 300, width: false, initialWidth: "600", innerWidth: false, maxWidth: false, height: false, initialHeight: "450", innerHeight: false, maxHeight: false, scalePhotos: true, scrolling: true, href: false, title: false, rel: false, opacity: 0.9, preloading: true, className: false, overlayClose: true, escKey: true, arrowKey: true, top: false, bottom: false, left: false, right: false, fixed: false, data: undefined, closeButton: true, fastIframe: true, open: false, reposition: true, loop: true, slideshow: false, slideshowAuto: true, slideshowSpeed: 2500, slideshowStart: "start slideshow", slideshowStop: "stop slideshow", photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i, // alternate image paths for high-res displays retinaImage: false, retinaUrl: false, retinaSuffix: '@2x.$1', // internationalization current: "image {current} of {total}", previous: "previous", next: "next", close: "close", xhrError: "This content failed to load.", imgError: "This image failed to load.", // accessbility returnFocus: true, trapFocus: true, // callbacks onOpen: false, onLoad: false, onComplete: false, onCleanup: false, onClosed: false }
maxWidth: falseを
maxWidth: 95% とかにするとそれなりに収まって表示されます。
例)このブログは以下のように設定します。
if($("a[rel='colorbox']").colorbox) { $("a[rel='colorbox']").colorbox({fixed:'true',transition:'fade',maxWidth:'96%',maxHeight:'90%'}); }
CSSは古いアンドロイド対応の為に
#cboxOverlay{position:fixed; width:200%; height:200%;}
にしています。
正しい対応方法ではないですがwww
とにかくこれでそれなりに表示されています。