7

有时照片纵横比与幻灯片容器不同,我看到照片会被拉伸以填充所有容器空间。

有没有办法避免这种情况,使照片纵横比不改变?当然会有一些空白,但照片中的形状没有改变。

4

1 回答 1

18

请设置 $FillMode 选项,0:拉伸,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>

参考:Jssor 滑块选项

于 2014-05-26T08:31:50.410 回答