简体   繁体   English

Cycle2滑块无法为基于百分比的宽度设置动画?

[英]Cycle2 slider cannot animate percentage based widths?

I'm working on a site that will be responsive. 我正在一个会做出响应的网站上工作。 I'm trying to implement a slider with content inside it, and am using Cycle2 for it's simplicity. 我正在尝试实现一个内部包含内容的滑块,并且为了简单起见,正在使用Cycle2。

I've got most of it together, the one thing I'm having problems with is that percentage widths do not work well in Cycle2 sliders... 我已经把大部分东西放在一起了,我遇到的一件事是百分比宽度在Cycle2滑块中不能很好地工作...

Essentially I have one picture which is width;100% of it's container, and another two which are 50% of their container, and sit side by side. 本质上,我有一幅是宽度的照片;它是容器的100%,另外两幅是其容器的50%,并排坐着。 You can see it all here on the demo page I've made. 您可以在我制作的演示页面上看到所有内容。 But there is also a codepen (although it's harder to see here, but the code is the same). 但是也有一个Codepen (尽管在这里很难看到,但是代码是相同的)。

The problem is that in order to Cycle through, Cycle2 seems to play with the width of the container. 问题在于,为了进行循环,Cycle2似乎在使用容器的宽度。 This means that all my pictures are are also affected as they are based off percentage widths. 这意味着我的所有图片都受到影响,因为它们基于百分比宽度。 If you click "next" you'll see the animation looks weird as the pictures animate to different sizes before disappearing. 如果单击“下一步”,您将看到动画看起来很奇怪,因为图片在消失之前会以不同的大小进行动画处理。 I want everything to stay the same, but simply scroll off. 我希望所有内容都保持不变,但只需滚动即可。

I'm just wondering what your solutions to this would be, I'd really prefer to use Cycle2 as I know it's nice and easy to style but maybe it's not possible. 我只是想知道您对此的解决方案是什么,我真的更喜欢使用Cycle2,因为我知道它很好并且易于样式设置,但也许是不可能的。 Or how else would you work a responsive design in this case? 或者在这种情况下,您将如何进行响应式设计?

<div class="slider cycle-slideshow"
        data-cycle-fx="scrollHorz"
        data-cycle-pause-on-hover="false"
        data-cycle-speed="400"
        data-cycle-timeout=0
        data-cycle-slides="> div.slideItem"
        data-cycle-prev="#prev"
        data-cycle-next="#next"
        data-cycle-auto-height=true
        >

This was solved by adding width:100% to .slideItem 这是通过将width:100%添加到.slideItem.slideItem

http://codepen.io/anon/pen/rgxka http://codepen.io/anon/pen/rgxka

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

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