有时照片的长宽比与幻灯片容器不同,我看到照片将被拉伸(stretch)以填充所有的容器空间。

有什么选择可以避免这种情况,以使照片的宽高比保持不变?肯定会有一些空白,但是照片中的形状不会改变。

最佳答案

请设置$ 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 Slider Options

关于Jssor-如何保持图像长宽比?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23865571/

10-13 07:24