Jssor - 如何保持图像纵横比?

标签 jssor

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

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

最佳答案

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

相关文章:

javascript - jssor 附近的 slider 不透明度即将到来的照片

transition - 自动播放时 JSSOR 转换不起作用

javascript - jssor 画廊不能一起使用缩略图和标题

jquery - 如何使用没有固定高度和宽度的 JSSOR slider

slider - 是否可以在页面刷新时使用不同的幻灯片启动 JSSOR slider ?

jquery - jssor slider 问题 - 最小化低于 1200px 的窗口时添加滚动

javascript - JSSOR slider 不可见

javascript - 鼠标悬停时的 Jssor 光标

javascript - 在带有 ui-view 的 angularjs 中使用 jssor slider 时出现错误

jquery - Jssor slider : Captions overlap for a short time before slideshow starts