在 div 集中包含 Galleria Gallery 以不显示任何内容

发布于 2024-11-19 16:37:16 字数 277 浏览 3 评论 0原文

我在 div 中有一个画廊,最初设置为不显示,这是因为我在同一页面上有 5 个这样的画廊,并且只想一次显示一个。现在,每当我单击链接显示其中一个画廊时,我都会收到一个致命错误:

Fatal error: Could not extract a stage height from the CSS. Traced height: 0px.

有没有办法解决这个问题?我的 javascript 知识不是很好,但任何帮助将不胜感激。

谢谢。

乔尼

I've got a gallery in div which is initially set to display none, this is because I have 5 of these galleries on the same page and only want one to display at any one time. Now whenever i click the link to display one of the galleries i'm getting a fatal error:

Fatal error: Could not extract a stage height from the CSS. Traced height: 0px.

Is there anyway to work around this? My javascript knowledge isn't great, but any help would be greatly appreciated.

Thanks.

Joni

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请恋爱 2024-11-26 16:37:17

无论显示画廊容器的事件是什么,您都需要初始化画廊实例。

我也遇到了同样的问题 - 默认情况下,我的画廊在我的页面上是隐藏的(不显示),只有当您单击“查看画廊”链接时才会出现。使用 jQuery SlideDown(它将显示属性设置为阻止),然后我才调用初始化。

$("#gallery-wrapper").galleria({ height: 500, width: 500 });

You need to intialize the gallery instance on whatever event it is that displays the gallery container.

I have been experiencing the same issue - my gallery is hidden (display none) by default on my page and only appears when you click a link "View gallery". Using jQuery slideDown (which sets the display property to block), only then do I call the initialize.

$("#gallery-wrapper").galleria({ height: 500, width: 500 });
·深蓝 2024-11-26 16:37:17

这个函数

$(".portfolio-links a").click(function() {});

你可以重新调用

$(".gallery").galleria({
    width: 605,
    height: 550,
    autoplay: 3000,
    transition: 'fadeslide'
});

但也许使用唯一的ID,这样你就不会做不必要的工作

Is this function

$(".portfolio-links a").click(function() {});

You may able to re-call

$(".gallery").galleria({
    width: 605,
    height: 550,
    autoplay: 3000,
    transition: 'fadeslide'
});

But maybe use unique ID's so you're not doing unneeded work

时光倒影 2024-11-26 16:37:17

我会使用 javascript 在获得高度后隐藏元素。问题是它无法获取 display:none; 元素的高度,它的结构就像幽灵一样,无形。

另外,我认为修复网站可以做的最简单的事情就是向与链接相关的每个链接添加 rel 标记,例如 rel="graphic"rel="packaging " 为每个 div 添加一个类似的标签。

用它来切换不同的画廊。另外,您只针对一个带有 jquery Cycle 插件的画廊,我建议:

$('.portfolio-body').cycle({
    fx: 'scrollLeft',
    speed:   2000, 
    timeout: 3000, 
    next:   '#catalogue-display'
});

这样它就可以针对所有画廊。此外,Galleria 插件似乎至少在 jsFiddle 示例中不起作用。我认为它会与 jQuery Cycle 插件冲突。

我还会更改 onClick 处理程序以使用 rel 来了解要显示哪个图库。并使用类似的东西来隐藏剩余的内容。

$(".portfolio-links a").click(function() {
    $('.portfolio-body').hide();
    var rel = $(this).attr("rel");
    $('.portfolio-body[rel="'+rel+'"').show();
});

我知道我所说的大部分内容与您最初的问题不太相关,但我将从这里开始,它可能会解决您最初的问题。 注意:我没有遇到您上面描述的相同错误

I would use javascript to hide the element after it obtains the height. The issue is that it cannot get the height of an element that is display:none; it's structure is like a ghost, intangible.

Also I am thinking the easiest thing you can do to fix your site is adding a rel tag to each link that is pertinent to the link such as rel="graphic" and rel="packaging" add a similar tag to each div that.

Use that to toggle the different galleries. Also you are targeting only one gallery with the jquery cycle plugin, I would suggest:

$('.portfolio-body').cycle({
    fx: 'scrollLeft',
    speed:   2000, 
    timeout: 3000, 
    next:   '#catalogue-display'
});

That way it targets all of them. Also the Galleria plugin seems to not work at least in the jsFiddle example. I would assume that it would conflict with the jQuery Cycle plugin.

I would also change the onClick handler to use the rel to know which gallery to display. And to hide the remaining using something as such.

$(".portfolio-links a").click(function() {
    $('.portfolio-body').hide();
    var rel = $(this).attr("rel");
    $('.portfolio-body[rel="'+rel+'"').show();
});

I know most of what I said is not too pertinent with your original question but I would start here it may fix your initial issue. Note: I did not run into the same error you described above

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文