简体   繁体   English

jQuery Cycle插件不起作用

[英]jQuery Cycle plugin not working

There is a website in which there's a section which I'm trying to replicate within JSFiddle and play around with it. 有一个网站,其中有一个部分我正在尝试在JSFiddle中复制并使用它。

One thing that I'm having trouble with is this: 我遇到的一件事是:

在此处输入图片说明

These two small <- -> buttons are used to switch between testimonials. 这两个小<- ->按钮用于在个人鉴定之间切换。 This switching is being done by jQuery Cycle Plugin . 此切换由jQuery Cycle Plugin完成

The problem is that I can't get these buttons to work within JSFiddle. 问题是我无法在JSFiddle中使用这些按钮。

I have imported the same jquery.cycle.all.2.74.pack.js file used on the original website, and have also added jQuery. 我已经导入了原始网站上使用的相同的jquery.cycle.all.2.74.pack.js文件,并且还添加了jQuery。 So I don't know what else is missing. 所以我不知道还有什么。

My JSFiddle Replica: http://jsfiddle.net/ahmadka/FsSxd/ 我的JSFiddle副本: http : //jsfiddle.net/ahmadka/FsSxd/

Original Website: http://bit.ly/16447fr (To avoid search engine indexing) 原始网站: http : //bit.ly/16447fr (为避免搜索引擎索引)

This is where these <- -> buttons are used on the original Website: 在原始网站上使用以下<- ->按钮的位置:

在此处输入图片说明

A couple of things were needed to get this functioning correctly. 要使此功能正常运行,需要做几件事。 First of all, you were never calling cycle() : 首先,您从未调用过cycle()

$('.scrollable4 .items').cycle({
  timeout: 0, 
  next: '.next',
  prev: '.prev',
  fx: 'scrollRight',
  easing:  'easeInOutBack' 
})

Secondly, to mimic the effect you're looking for, you need the easing.js plugin (see external resource in jsfiddle linked below). 其次,为了模仿您想要的效果,您需要easing.js插件(请参阅下面链接的jsfiddle中的外部资源)。

Finally, within your CSS, you can't float the elements, they need to be absolutely positioned and given a height of 100%. 最后,在CSS中,您无法浮动元素,它们必须绝对定位并具有100%的高度。

#divleftcontent2 .scrollable4 .items {
  position: absolute;
  height: 100%;
}

There are other ways to fix the height issue but that is a different question. 还有其他方法可以解决高度问题,但这是一个不同的问题。

I have updated the fiddle to show what I think is the final version you are looking for: http://jsfiddle.net/FsSxd/8/ 我已经更新了小提琴以显示我认为您正在寻找的最终版本: http : //jsfiddle.net/FsSxd/8/

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

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