1
jQuery custom content scrollerの画像スケーリングのバグを避けるベストプラクティスは何ですか?jQueryカスタムコンテンツスクロールの画像スケーリングのバグを回避する
問題の結果、画像はwidth: 100%
に設定されています。カスタムスクロールバーが追加されるとwidth
が変更され、height
に影響し、スクロールバーが必要ない部分の内容が減少します。
jsfiddle下またはとしての例を参照してください:
$(document).ready(function() {
$("#content").mCustomScrollbar({
axis: 'y',
theme: 'dark-3'
});
});
html { background-color: #ccc; }
.container { height: 200px; width:180px; overflow:auto; }
.image { width: 100%; }
.test { background-color: #fff; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.1/jquery.mCustomScrollbar.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.1/jquery.mCustomScrollbar.concat.min.js"></script>
<div id="content" class="container">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/NGC_1232.jpg/300px-NGC_1232.jpg" class="image" />
<div class="test">Astronomy</div>
</div>