简体   繁体   English

ScrollMagic,反向Z索引顺序

[英]ScrollMagic, reverse z-index order

I'm using scrollmagic to tween svg clippaths as you scroll. 当您滚动时,我正在使用scrollmagic来补间svg剪切路径。 Usually with svgs(or divs or sections or whatever) the last thing you specify in your html is on top in terms of z-index, but you change that in css. 通常,对于svgs(或div或sections或其他),您在html中指定的最后一件事就z-index而言是最重要的,但是您可以在css中进行更改。 I tried to do this with my svgs, so that while the first svg tweens, the other one scrolls up behind it. 我尝试使用svg做到这一点,以便在第一个svg补间时,另一个在其后滚动。 It seems like scrollmagic is preventing my z-indexing from working though. 似乎scrollmagic阻止了我的z-indexing工作。 Any ideas? 有任何想法吗?

http://codepen.io/kathryncrawford/pen/BoXOMJ http://codepen.io/kathryncrawford/pen/BoXOMJ

<div id="scene">

<svg id="svg1" height="500" width="800">
<image id="img1" xlink:href="http://placecage.com/800/500" x="0" y="0" width="800" height="500"/>
<defs>
    <clipPath id="clip1">
        <circle id="circle1" stroke="#000000" stroke-miterlimit="10" cx="400" cy="300" r="300" />
    </clipPath>
</defs>
</svg>

</div>

<div id="scene2">

<svg id="svg2" height="500" width="800">
<image id="img2" xlink:href="http://fillmurray.com/800/500" x="0" y="0" width="800" height="500"/>
<defs>
    <clipPath id="clip2">
        <circle id="circle2" stroke="#000000" stroke-miterlimit="10" cx="400" cy="300" r="300" />
    </clipPath>
</defs>
</svg>

</div>

CSS CSS

#img1 {
clip-path: url(#clip1);
}

#img2 {
clip-path: url(#clip2);
}

#svg1, #circle1{
z-index: 2;
}

#svg2, #circle2{
z-index: 1;
}

Crap, I literally just figured it out after posting this. 废话,我只是在发布之后才弄清楚了。 I changed the z-index css declaration to the z-index on the scene divs that wrap the svgs. 我将包裹SVG的场景div上的z-index css声明更改为z-index。 That worked. 那行得通。

http://codepen.io/kathryncrawford/pen/BoXOMJ http://codepen.io/kathryncrawford/pen/BoXOMJ

#scene{
z-index: 2;
}

#scene2{
z-index: 1;
}

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

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