首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从div启动Stellar.js

无法从div启动Stellar.js
EN

Stack Overflow用户
提问于 2012-09-03 16:09:47
回答 1查看 1.2K关注 0票数 0

我正在尝试将Stellar.js (http://markdalgleish.com/projects/stellar.js/)实现到我正在开发的站点。我意识到我需要将视差滚动封闭在容器中,而不是使用窗口/主体,以便它在iPad上工作(考虑到视口),这就是我遇到问题的地方;脚本似乎不能正确启动。

这是我在网站上设置的结构-

HTML

代码语言:javascript
复制
    <header></header>
        <!-- keeping this content outside of #content because of a prefixed alignment -->

        <div id="content">

        <section id="example" data-stellar-background-ratio="1">
            <img src="example-1.png" data-stellar-ratio="2" data-stellar-offset="-25">
            <img src="example-2.png" data-stellar-ratio="3" data-stellar-offset="-50">
            <img src="example-3.png" data-stellar-ratio="4" data-stellar-offset="0">
        </section>

    </div>

CSS

代码语言:javascript
复制
    #content {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

section {

        background-attachment: fixed;
        width: 100%;
        height: 100%;
        position: relative;
    }
        img:first-child {
            position: absolute;
            top: 0;
            left: 300px;
        }
        img:nth-child(2) {
            position: absolute;
            z-index: 99;
            top: 0;
            right: 150px;
        }
        img:nth-child(3) {
            position: absolute;
            z-index: 99;
            top: 0;
            left: 100px;
        }

JavaScript

代码语言:javascript
复制
 $('#content').stellar({
        horizontalScrolling: false
    });

我可以看到部分中的视差图像显示为: none,但除此之外,脚本似乎没有运行。我没有收到JS错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-03 18:15:04

我在想,这可能与你使用position: absolute而不给div任何与有关。

你检查过你的#content分区的大小了吗?还是说星空也会处理这件事?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12244124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档