简体   繁体   English

是否可以使用具有固定高度的全宽JSSOR滑块?

[英]Is it possible to have full width JSSOR slider with fixed height?

I'm trying to use JSSOR slider on a website. 我正在尝试在网站上使用JSSOR滑块。 I already figured out how to make it full width but now it's all "responsive" so it scales even the height of the slide. 我已经想出如何使它全宽,但现在它全部“响应”,所以它甚至可以缩放幻灯片的高度 I would like to have fixed height (400px) and 100% width. 我想要固定高度 (400px)和100%宽度。 I almost achieved it so the "slider1_container" is full width and 400px height but the content of it is still responsive. 我几乎实现了它,所以“slider1_container”是全宽和400px高度,但它的内容仍然是响应。

There's the website: http://carwash-horovice.cz 有网站: http//carwash-horovice.cz

I appreciate any help you can give me. 我感谢你能给我的任何帮助。

To scale jssor slider, it will always keep aspect ratio. 要缩放jssor滑块,它将始终保持纵横比。 You cannot scale with without scaling height. 如果没有缩放高度,则无法缩放。

If you want to keep the original height, you can disable scaling by removing the following code. 如果要保持原始高度,可以通过删除以下代码来禁用缩放。

    function ScaleSlider() {
        var parentWidth = $('#slider1_container').parent().width();
        if (parentWidth) {
            jssor_slider1.$ScaleWidth(parentWidth);
        }

        else
            $JssorUtils$.$Delay(ScaleSlider, 30);
    }

    ScaleSlider();
    $(window).bind("load", ScaleSlider);
    $(window).bind("resize", ScaleSlider);
    $(window).bind("orientationchange", ScaleSlider);

In addition, to keep your page responsive and keep the slider auto center, you can wrap the slider by a wrapper. 此外,为了使页面保持响应并保持滑块自动居中,您可以通过包装器包裹滑块。

<div style="position: relative; width: 100%; overflow: hidden;">
    <div style="position: relative; left: 50%; width: 5000px; text-align: center; margin-left: -2500px;">

        <!-- use 'margin: 0 auto;' to auto center element in parent container -->
        <div id="slider1_container" style="...margin: 0 auto;..." ...>
        </div>

    </div>
</div>

You have an example with the slider at full screen. 你有一个全屏滑块的例子。

http://www.jssor.com/testcase/full-screen-slider.source.html http://www.jssor.com/testcase/full-screen-slider.source.html

This is what I'm looking for, but with a limited height. 这就是我正在寻找的,但身高有限。 I don't want the aspect ratio of the images to change, but as in the full-screen version, I'd like it to expand to fill the width, and simply crop what doesn't fit within the fixed height. 我不希望图像的宽高比发生变化,但是在全屏版本中,我希望它能够扩展以填充宽度,并简单地裁剪出不适合固定高度的内容。 Is this possible? 这可能吗?

您可以通过注释$(window).bind(“resize”,ScaleSlider)来修复轮播的高度;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM