###前提・実現したいこと
lightboxのカスタマイズをしています。
画像が大きすぎるとブラウザの画面に合わせて縮小されますが、原寸大で表示したいです。
でもスマホからは画面の横幅を超える場合は縮小してほしいです。(縦幅は無視してほしいです)
ブラウザの横幅を基準に設定したいのですが上手くできません。
###発生している問題・エラーメッセージ
検索したら「fitImagesInViewport: true,」を「fitImagesInViewport: false,」にすると画像が原寸大になることが分かりました。
パソコンから見る分にはそれでよかったのですが、これをスマホから見ると画像がはみ出てしまいます。
スマホから「fitImagesInViewport: true,(非原寸大)」で見ると、少しでも縦に長い画像は小さくなりすぎることがあります。
###該当のソースコード
// Descriptions of all options available on the demo site: // http://lokeshdhakar.com/projects/lightbox2/index.html#options Lightbox.defaults = { albumLabel: 'Image %1 of %2', alwaysShowNavOnTouchDevices: false, fadeDuration: 600, fitImagesInViewport: true, imageFadeDuration: 600, // maxWidth: 800, // maxHeight: 600, positionFromTop: 50, resizeDuration: 0, showImageNumberLabel: true, wrapAround: false, disableScrolling: false, /* Sanitize Title If the caption data is trusted, for example you are hardcoding it in, then leave this to false. This will free you to add html tags, such as links, in the caption. If the caption data is user submitted or from some other untrusted source, then set this to true to prevent xss and other injection attacks. */ sanitizeTitle: false };
###試したこと
var windowWidth = $(window).width(); var windowSm = 480px; if (windowWidth <= windowSm) { 内容 }
if (window.matchMedia('screen and (max-width:480px)').matches) { 内容 });
この辺りが使えるのでは、と考えているのですが、組み込み方と動作させるべき内容が分かりません。
CSS側でも@media screenで画像の部分を「max-width: 100%;」にしてみましたが効果がないようです。
###補足情報(言語/FW/ツール等のバージョンなど)
公式サイトから最近DLしたばかりです。
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。