有时照片宽高比与幻灯片容器不同,我看到照片会被拉伸以填满所有容器空间。
是否有任何选项可以避免这种情况,使照片长宽比不变?肯定会有一些空白,但照片中的形状不会改变。
答案 0 :(得分:18)
请设置$ FillMode选项,0:streach,1:包含,2:封面,4:实际尺寸,5:包含大图像和小图像的实际尺寸。
值1或2或4是保持宽高比
的不错选择<script>
jQuery(document).ready(function ($) {
var options = {
$FillMode: 1, //[Optional] The way to fill image in slide, 0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actuall size, 5 contain for large image and actual size for small image, default value is 0
$AutoPlay: true, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
$DragOrientation: 3 //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
};
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
});
</script>