简体   繁体   English

Zurb Foundation 4.3.0 Orbit没有显示幻灯片

[英]Zurb Foundation 4.3.0 Orbit not showing slides

I'm using Foundation 4.3.0 for a project, and am trying to set up Orbit in the most basic way. 我正在使用Foundation 4.3.0进行项目,并试图以最基本的方式设置Orbit。 The javascript and CSS seem to be loading correctly, the images are loading, all the extra elements are inserted, etc. But the main <ul> always has a height of 0px. javascript和CSS似乎正确加载,图像正在加载,所有额外的元素都插入,等等。但主<ul>的高度始终为0px。 Here's my HTML: 这是我的HTML:

<div class="row">
    <section class="large-12 columns">
        <div class="slideshow-wrapper">
            <div class="preloader"></div>
            <ul data-orbit="">
                <li><img src="/media/cache/8a/ec/8aec9d6a99dea3db235f24712e8f3f88.jpg"></li>
                <li><img src="/media/cache/20/88/208812a64eee2e7e9b8efe4b5f73c990.jpg"></li>
            </ul>
        </div>
    </section>
</div>

Here's the HTML once foundation.orbit.js does its thing: 这是HTML一旦foundation.orbit.js做了它的事情:

<div class="row">
    <section class="large-12 columns">
        <div class="slideshow-wrapper">
            <div class="preloader"></div>
            <div class="orbit-container orbit-stack-on-small">
                <ul data-orbit="" class="orbit-slides-container" style="margin-left: -100%; width: 400%; height: 0px;">
                    <li data-orbit-slide="" style="width: 25%;"><img src="/media/cache/20/88/208812a64eee2e7e9b8efe4b5f73c990.jpg"></li>
                    <li class="active" style="width: 25%;"><img src="/media/cache/8a/ec/8aec9d6a99dea3db235f24712e8f3f88.jpg"></li>
                    <li style="width: 25%;"><img src="/media/cache/20/88/208812a64eee2e7e9b8efe4b5f73c990.jpg"></li>
                    <li data-orbit-slide="" style="width: 25%;"><img src="/media/cache/8a/ec/8aec9d6a99dea3db235f24712e8f3f88.jpg"></li>
                </ul>

                <a href="#" class="orbit-prev">Prev <span></span></a>
                <a href="#" class="orbit-next">Next <span></span></a>

                <div class="orbit-slide-number">
                    <span>1</span> of <span>2</span>
                </div>

                <div class="orbit-timer">
                    <span></span>
                    <div class="orbit-progress" style="overflow: hidden; width: 54.15%;"></div>
                </div>
            </div>

            <ol class="orbit-bullets">
                <li data-orbit-slide-number="1" class="active"></li>
                <li data-orbit-slide-number="2" class=""></li>
            </ol>
        </div>
    </section>
</div>

I have tried to put explicit width + height on the images, put class="active" on one slide when generating the HTML, change various Foundation settings, etc, and nothing seems to work. 我试图在图像上放置显式的宽度+高度,在生成HTML时将class="active"放在一张幻灯片上,更改各种Foundation设置等,似乎没有任何效果。

When I compare the HTML to the live example in the Foundation docs, I notice that in the working version, a z-index is always set dynamically on the slides. 当我将HTML与Foundation文档中的实例进行比较时,我注意到在工作版本中,始终在幻灯片上动态设置z-index On my site, no z-index is ever set. 在我的网站上,没有设置z-index And of course, the ul in the working version has an inline CSS height which equals the height of the slides. 当然,工作版本中的ul具有内联CSS高度,该高度等于幻灯片的高度。

If I manually set the ul height to 300px, everything looks right, except I see no images. 如果我手动将ul高度设置为300px,一切看起来都正确,除了我看不到图像。 If I set div.orbit-container to overflow: visible , I will see the edge of one of the slides to the left of the container. 如果我将div.orbit-container设置为overflow: visible ,我将看到容器左侧的一个幻灯片的边缘。

Any ideas would be much appreciated. 任何想法将不胜感激。

I'm going to try to avoid being overly verbose here.. but this is what I've found and while I wouldn't call this a complete fix, because i'm not sure what started the differences in css the following code solved the problem. 我将尽力避免在这里过于冗长..但这是我发现的,虽然我不会称之为完全修复,因为我不确定是什么启动了css中的差异以下代码解决了问题。

I found this because I have a local environment as well as a dev environment for the site. 我发现这是因为我有一个本地环境以及该网站的开发环境。 The local environment was working great, but the production environment had all the issues you mentioned above. 当地环境运作良好,但生产环境有上面提到的所有问题。

The first issue of course is the generated container div setting the height to 0px. 第一个问题当然是生成的容器div将高度设置为0px。 This is strange enough. 这很奇怪。 I manually added the height to the container in the css. 我手动将高度添加到css中的容器中。 The reason all the images are hiding is they're set to margin-left: 100% or some large left margin and they're all positioned absolutely. 所有图像隐藏的原因是它们被设置为左边距:100%或一些大的左边距,它们都是绝对定位的。 I wish I could be more help as to why the code differences are present, maybe I'll find more time to investigate further but for now its working. 我希望我能更多地帮助解决为什么存在代码差异,也许我会找到更多时间进一步调查,但现在它的工作。

Anyway, the following was the fix: 无论如何,以下是修复:

.orbit-container { height:250px; }  

.orbit-container .orbit-slides-container > * {
  position: relative;
  margin-left: 0;
  float: left;
  height: 100%;
}
.orbit-container { height:auto; }  

.orbit-container .orbit-slides-container > * {
  position: relative;
  margin-left: 0;
  float: left;
  height: 100%;
}

A little upgrade from a previous solution. 从以前的解决方案稍微升级。 With this modification, it will be more easy to show the slideshow on a phone and a desktop. 通过此修改,可以更轻松地在手机和桌面上显示幻灯片。

Are you sure the url to the images are ok? 你确定图像的网址是否正常? I had the same problem but with 2 of my 3 images and the problem was in the url 我有同样的问题,但我的3张图片中有2张,问题出现在网址中

我遇到了同样的问题,我刚刚发现使用单个模块(我使用指南针)而不是使用foundation.min.css解决了问题,你试过使用foundation.css(不是minyfied)吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM