Galleria致命错误:无法从CSS中提取舞台高度.追踪高度:0px

SLo*_*ret 36 jquery galleria

如果我有该行<style type="text/css"></style>,即使它是空白的,Galleria会抛出错误消息"致命错误:无法从CSS中提取舞台高度.跟踪高度:0px."

看来即使我告诉Galleria使用300的高度:

$('#galleria').galleria({ 
width: 300, 
height: 300, 
transition: 'fade' 
}); 
Run Code Online (Sandbox Code Playgroud)

它试图首先确定高度,而CSS行令人困惑,因此它会抛出此错误.如果我删除那一行,不再有错误.

无论如何我仍然可以使用<style type="text/css"></style>?我们使用它来根据客户使用它来定制我们网站的外观和感觉.

小智 53

确保包括:

头:

<link type="text/css" rel="stylesheet" href="galleria/themes/classic/galleria.classic.css">
<script type="text/javascript" src="js/galleria-1.2.5.min.js"></script>
<script type="text/javascript" src="galleria/themes/classic/galleria.classic.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

还有页面样式:

#galleria{height:467px}
Run Code Online (Sandbox Code Playgroud)

在图像下方:

<script type="text/javascript">
$('#gallery').galleria({
width: 700,
height: 467 //--I made heights match
});
</script>
Run Code Online (Sandbox Code Playgroud)

如果您在使用干净安装进行故障排除时遇到问题并添加,直到找到原因.

  • 如果我不想指定高度怎么办?喜欢响应式布局? (4认同)

Sap*_*huA 11

你需要给galleria图像容器一个css的高度.这是galleria展示图像的地方(所以它应该小于拱廊本身的高度).

.galleria-stage {
    height: 450px;
    position: absolute;
    top: 10px;
    bottom: 60px;
    left: 10px;
    right: 10px;
    overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud)


Div*_*Das 10

它可能对某些人有所帮助,他仍然会收到此错误: -

我收到此错误是因为我有一个隐藏的画廊.

FIX: - 在CSS中给图库div一个高度,然后在js文件中,

Galleria.run('#gallery', {
  height: parseInt($('#gallery').css('height')),
  wait: true
 });
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅以下链接: - http://galleria.io/docs/references/errors/

http://galleria.io/docs/options/wait/


小智 5

我只在IE中遇到此错误.解决方案是强制高度.

在galleria.classic.css CSS中为类添加高度 .galleria-stage

例.

.galleria-stage { 
  height:450px; <-- set this to any height and i should work :)
  position: absolute; 
  top: 10px; 
  bottom: 60px; 
  left: 10px; 
  right: 10px; 
  overflow:hidden;
} 
Run Code Online (Sandbox Code Playgroud)