0

我对 skrollr 和 z-index 有点问题。

http://i.imgur.com/whCViHV.png

我正在尝试将图片放在顶部以放在博客文章的下方。
我一生都无法弄清楚为什么,无论我在哪里/如何应用 z-index(我认为这是我应该做的),图像总是位于帖子上方。
我已经尝试了我能想到的一切,将它放在 div 中,放在 css 中......
您可以通过将帖子放在 skrollr div 中来使其位于博客帖子下方,但随后我遇到了很多行高问题.
我已经删除了所有失败的 z-index 尝试,因此它应该与我的旧的愚蠢代码“无冲突”。

http://jsfiddle.net/8fb4C/(不是 100% 确定这是正确完成的)
https://github.com/pxlprfct/Blog-SO-Question

<div id="skrollr-body">
        <div id="test" 
            data-0="top:0px;"
            data-1000="top: 400px;" >
           <img src="apple.jpg" alt="">
        </div>
    </div>

    <article>
        <h1>
            Hi there helpful person!
        </h1>
        <p> 
            Hi there, I've been trying, and failing, to do what I thought was a reasonably simple thing.
        </p>
        <p>
            I just want the picture to stay where it is, (don't worry about the horrible aspect ratio and how it looks crushed, I'm fixing that after) and the 'blog', well the article to overlap it.
        </p>
        <p>
            I've been pratting around with z-index and have done pretty much everything I can think of, but the image still persists to scroll on top of the text (rather than underneath).
        </P>
        <p>
            I have tried a few sketchy things that worked, but didn't work well. I think i'm missing something mega obvious, anyways. Thanks for being awesome :)
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt earum eum recusandae accusantium porro facere vero nulla delectus. Adipisci, omnis velit molestias nemo expedita! Ad, enim similique placeat rerum. Libero.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores, fuga eius ipsa alias repudiandae itaque neque totam veniam ut minus dignissimos eveniet dicta unde quos enim possimus optio nihil omnis. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat, magni est officia quis vitae veritatis doloribus laudantium corporis doloremque ratione ut ullam voluptatibus numquam quos optio voluptas veniam corrupti repellat. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad, provident, maxime beatae ea distinctio aperiam dicta ipsa soluta consequatur eius explicabo cumque possimus iure temporibus laudantium eveniet et ex placeat.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Incidunt, quidem sint labore saepe explicabo aspernatur sunt vero quos minima nesciunt velit et debitis est accusantium eveniet dolorum sed quibusdam voluptate!
        </p>
    </article>
4

1 回答 1

3

添加position: fixed和调整z-indexto-1就可以了。您还必须将topand设置left0,但这是次要的:

#test {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

JSFiddle:http:
//jsfiddle.net/8fb4C/1/

于 2013-04-18T17:14:32.190 回答