Jquery Cycle - 如何使用循环进行寻呼?
让我的寻呼机在 jquery 周期中看起来正确时遇到问题。 以下代码
$(document).ready(function() {
$('#slider_container')
.after('<div id="pager">')
.cycle({
fx: 'scrollRight',
speedIn: 400,
speedOut: 200,
timeout: 10000,
pause: 1,
delay: -4000,
easeIn: 'easeInCirc',
sync: false,
pager: '#pager',
pagerAnchorBuilder: function(idx, el) {
return '<li><a href="#"><img src="images/grey_dot.png" width="10" height="10" /></a></li>';
}
});
});
让我将图像显示为导航而不是数字,但问题是我希望能够为活动幻灯片提供不同颜色的圆圈。
我尝试将 img 位保留在 pageAnchorBuilder 之外,并在 CSS 中使用 backgrounf:(url) 并在 .activeSlide 上使用不同的一个,但无济于事。
将不胜感激任何人的帮助,谢谢。
Am having a problem getting my pager to look right with jquery cycle.
The following code
$(document).ready(function() {
$('#slider_container')
.after('<div id="pager">')
.cycle({
fx: 'scrollRight',
speedIn: 400,
speedOut: 200,
timeout: 10000,
pause: 1,
delay: -4000,
easeIn: 'easeInCirc',
sync: false,
pager: '#pager',
pagerAnchorBuilder: function(idx, el) {
return '<li><a href="#"><img src="images/grey_dot.png" width="10" height="10" /></a></li>';
}
});
});
Has got me the images to show up as the navigation instead of the numbers but the problem is that I would like to be able to have a different coloured circle for the active slide.
I tried leaving the img bit out of the pageAnchorBuilder and using backgrounf:(url) in the CSS and a different one on .activeSlide but to no avail.
Would appreciate anyone's help, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道你说过你已经尝试过通过 css 设置它们的样式但没有成功?但理论上它应该有效。我想你应该再试一次。
示例:
这适用于我的本地主机。理想情况下,您可以使用页面锚构建器来隐藏数字:
我希望这会有所帮助!
编辑:
首先。以下是有关其工作原理的演示: http://jsfiddle.net/Lywtt/1/
现在,您应该尝试以下操作:
- 完全删除锚构建器
删除锚构建器后,您确实会看到带有幻灯片数量的简单链接,对吧?比如“123”
- 接下来我们要做的是设置此链接的样式,因此在 css 中添加以下内容:
显然,上面的大多数样式仅用于演示目的,一旦一切按您希望的方式工作,就可以将其删除。
这在理论上必须有效,但是如果仍然不起作用,请重新链接您更新的网站(没有锚构建器并使用新样式),我们可以再次检查。
编辑2:
很高兴听到它有效!现在使用图像而不是绿色和黄色(用于活动幻灯片)块非常容易。让我们再次从演示开始: http://jsfiddle.net/Lywtt/2/
我们需要什么要做的事情如下:
只需将 css 替换为如下内容:
如您所见,我们只需将
background:green;
和background:yellow;
替换为相应的图像。当然,您必须调整图像的链接以匹配您的网站结构。您现在应该看到以图像为背景的数字,而不是绿色和黄色背景。
作为最后一步,我们要删除这些数字。为此,我们必须再次在脚本中插入一个简单的anchorBuilder:
您会看到我们插入了一个简单的anchorBuilder来显示空链接(没有数字)。
现在您应该只能看到没有数字的图像。
如果我没有犯错或其他错误,现在一切都应该正常。如果没有,请毫不犹豫地说出来!
问候!
I know you said you have already tried to style them via css and it didnt work? But in theorie it should work. I think you should try again.
Sample:
This works on my localhost. Ideally you can use the page anchor builder to hide the numbers:
I hope this helps!
EDIT:
First of all. Here is a demo on how it should work: http://jsfiddle.net/Lywtt/1/
Now, you should try following:
-remove the anchor builder completly
Once you remove the anchorbuilder you do see simple links with the number of slides, right? Like "123"
-Next thing we want to do is to style this links, so add the following in your css:
Obviously, most of the styles above are just for demo purpose and can be removed once everything works as you wish.
This must work in theory, however if it still doesnt work, than relink your updated site (without the anchor builder and with the new styles) and we can check it again.
Edit 2:
Good to hear it works! Now using images instead of the green and yellow (for active slides) blocks, is quite easy. Lets start with a demo again: http://jsfiddle.net/Lywtt/2/
What we need to do is following:
Simply replace the css with something like this:
As you can see, we simply replace
background:green;
andbackground:yellow;
with the corresponding images. Of course you will have to adjust the links of the images to match your site structure.You should now see the numbers with the images as background instead of green and yellow backgrounds.
As a final step, we want to remove this numbers. To do so, we have to insert a simple anchorBuilder in our script again:
You see we insert a simple anchorBuilder to display empty links (no numbers).
Now you should be able to see the images only without numbers.
If i didnt make a typo or another mistake, everything should work fine now. If not, dont hesitate to say so!
Regards!