小编H.H*_*ain的帖子

响应式视图中 React Slick 滑块的宽度错误

我已经为我的网站实现了 React Slick Slider,它适用于桌面视图并相应地采用适当的宽度,但如果我切换到响应式视图,容器的宽度不正确并且看起来全部扭曲。

我尝试用 CSS 修复它,给slick-trackdiv 设置 100% 宽度,但没有任何效果。

以下是容器:slick-track,下面是添加的内联 CSS:

width: 2.14748e+08px;
opacity: 1;
transform: translate3d(-8.05305e+07px, 0px, 0px);
Run Code Online (Sandbox Code Playgroud)

以下是我在组件中初始化滑块的方式:

const settings = {
            dots: false,
            infinite: true,
            speed: 500,
            cssEase: 'linear',
            slidesToShow: this.props.data && this.props.data.upSell && this.props.data.upSell.length>=5?6:this.props.data&& this.props.data.upSell && this.props.data.upSell.length,
            rtl: rtl === "en" ? false : true,
            slidesToScroll: 1,
            asNavFor: null,
            arrows: false,
            initialSlide: rtl==="en"?0:2,
            responsive: [
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 1,
                        infinite: true,
                        initialSlide: rtl==="en"?0:3,
                        dots: false
                    }
                }
            ] …
Run Code Online (Sandbox Code Playgroud)

javascript responsive-design ecmascript-6 reactjs react-slick

5
推荐指数
1
解决办法
2万
查看次数