空附加
Chrome 和 Safari(Webkit 引擎)将 2 个额外的
添加到
列表中,类为“jcarousle-item-placeholder”。我怎样才能删除它? jCarousel在FF、IE和Opera中都可以。感谢您的帮助。
Chrome and Safari (Webkit engine) add 2 additional <li>
into <ul>
list with class 'jcarousle-item-placeholder'. How can I remove it? jCarousel in FF, IE and Opera is OK.
Thanks for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
就我而言,我添加了以下代码两次
,我删除了一个块,它对我有用。
In my case, I was adding the below code twice
I removed the one block and it worked for me.
我在 Safari 中看到过在同一个 ul 上调用 jcarousel 两次时出现此问题 - 如果您使用 CMS,这很容易做到,因为 jcarousel 可以由模块函数调用(例如
jcarousel_add()< /code> 与 Drupal 的 jcarousel 模块),您自己的模块代码包含的 js 文件,模板文件等。
值得通过注释掉您正在使用的呼叫来排除这种可能性
I've seen this problem occur in Safari when jcarousel is called twice on the same ul - if you are working with a CMS this can be easy to do as jcarousel could be called by a module function (e.g.
jcarousel_add()
with Drupal's jcarousel module), a js file included by your own module code, in a template file etc.It's worth excluding this as a possibility by commenting out the call you are working with
我也遇到了这个问题,结果是我的结束
li
标签之一被意外地写为而不是正确的
,这使得浏览器渲染额外的空 li 标签
I had this problem also, and it ended up being that one of my closing
li
tags was accidentally written as<li>
instead of the proper</li>
, which made the browser render extra empty li tags我找到了一个快速但肮脏的解决方案,通过将 css“display:none”添加到任何带有 jcarousel-item-placeholder 类的
中。
导航到您的 jcarousel.min.js 文件
查找(对我来说是第 249 行):
if(h.length===0) { h=this.create(e).addClass(this.className("jcarousel-item-placeholder"))
直接在此之后,没有空格添加:
.css({ "display":"none"}).attr("jcarouselindex",c);
检查 Chrome、Safari、IE 和 FF 是否都应按预期工作,两个空
应该消失。
我的 jcarousel.min.js 的代码部分:
I found a quick and dirty solution to the problem by adding css "display:none" to any
<li>
with the class jcarousel-item-placeholder.Navigate to your jcarousel.min.js file
Look for (Line 249 for me):
if(h.length===0){ h=this.create(e).addClass(this.className("jcarousel-item-placeholder"))
Directly after this with no spaces add:
.css({ "display":"none"}).attr("jcarouselindex",c);
Check Chrome, Safari, IE and FF all should work as expected the two empty
<li class='...jcarousel-item-placeholder...'></li>
should be gone.Code section from my jcarousel.min.js:
确保您的标签已定义高度和宽度属性,就像
我在列表项上出现的几个“jcarousel-item-placeholder”类遇到类似问题一样,我没有在标签上定义宽度。我相信 DOM 已准备就绪,但图像尚未加载,因为窗口 onload 事件尚未发生。如果不声明图像的宽度,jcarousel 无法正确计算宽度,直到加载窗口,在这种情况下,它似乎会插入占位符项目。
Make sure your tag has defined height and width attributes like so
I had similar issues with several 'jcarousel-item-placeholder' classes appearing on list-items, where I did not define width on my tag. I believe the DOM was ready, but the images were not loaded yet as the window onload event had not occurred. Without declaring the width of the image, jcarousel has no way of calculating width correctly until the window is loaded and in that scenario it seems to insert placeholder items.