jQuery 循环幻灯片在页面加载时重叠
我在许多项目中使用过jQuery Cycle。这次我遇到了一个非常奇怪的视觉故障。页面加载时,所有幻灯片都显示在彼此的顶部,然后当脚本循环浏览每张幻灯片时,它最终会自行修复(直到重新加载页面)。有关示例和代码,请点击此处。下图显示了所有浏览器中似乎都会发生的故障(在 Firefox 4、Safari 5、Chrome 10、IE8 中测试)
向每个幻灯片添加背景颜色确实“修复”了隐藏其他幻灯片的问题,但在我看来这并不是一个真正正确的解决方案。
整个下午都在与这个问题作斗争,我有点不知所措。任何帮助将不胜感激。
谢谢
I have used jQuery Cycle in numerous projects. This time round I am getting a really bizarre visual glitch. On page load, all the slides are shown on top of each other, then as the script cycles through each slide, it eventually fixes itself (until the page is reloaded). For the example and code click here. The image below shows the glitch which seems to be happening in all browsers (tested in Firefox 4, Safari 5, Chrome 10, IE8)
Adding a background colour to each slide div
does "fix" the problem in that it hides the other slides, but it isn't really a proper solution in my opinion.
Been battling with this all afternoon and I'm at a bit of a loss. Any help would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 div 标签中使用 style="display:none;"除了一个之外,我都给它们起了一个共同的类名。您也可以获取调用 div 的子级。加载时将其更改为“display:inline”。唯一显示的是没有显示的:none。
使用img标签的示例,原理相同:
in the div tag use style="display:none;" on all but one, and I gave them all a common class name. You could just get the children of the calling div too. On load change it to "display:inline". The only one to show is the one with no display:none.
Example using img tags, same principle:
您是否应该将 jQuery Cycle 的调用放在 head.js 的回调中
,或者只是取消 head.js,因为您没有使用任何 html5 /css3?
Should you not put your call to jQuery Cycle in the callback of head.js
Or just do away with head.js seeing as your not using any html5 /css3?
我使用自定义过渡来做到这一点,将显示设置为无,除了第一个,然后添加类似的内容......
这将在使用之前显示该项目!
I did it using a custom transition, set the display to none on all except maybe the first then add something like .....
This will show the item just before it's used!
我遇到了同样的问题,但通过遵循 Truk 在将每张幻灯片设置为显示时的答案来修复它:无(第一张除外),但不是将其更改为在页面加载时内联显示,而是在循环调用中执行以下操作:
希望这可以帮助别人!
I had the same problem, but fixed it by following Truk's answer in setting each slide to display: none (except the first one), but instead of changing it to display inline on page load, you do it in the cycle call as follows:
Hope this helps someone else out!
添加显示:无;到幻灯片,以便它们不会在页面加载时显示。
Add a display:none; to the slides so that they don't display on page load.