2015-07-21 69 views
1

我有一个的jsfiddle一些代码在这里:CSS3关键帧动画的不透明性突破的z-index为了

https://jsfiddle.net/hhn6r3zn/

基本上我使用CSS3关键帧动画一个div和我想要的影像将高于它 - 但即使在使用z-index时也不起作用。

The wrapper is correctly behind the image, but the animated div is not

然而,当我停下来改变工作透明度: https://jsfiddle.net/ax1566b0/

Opacity at 1 the image is working

代码:

.pulse { 
 
    width: 32px; 
 
    background: #1A4886; 
 
    height: 12px; 
 
    border-radius: 50%; 
 
} 
 

 
@keyframes twinkly { 
 
    0% {opacity: 1; width:0px;margin-left:14px; height:0px;z-index:0;} 
 
\t 
 
    100% {opacity: 0;z-index:0;} 
 

 
} 
 

 
.pulse { 
 
    animation: twinkly 2s infinite; 
 
\t margin: auto; 
 
\t margin-top: -14px; 
 
\t z-index: 0; 
 
} 
 

 
.switch{ 
 
\t width:50px; 
 
\t height:75px; 
 
} 
 

 
.pulse-wrapper{ 
 
\t z-index:0; 
 
    background:red; 
 
} 
 
.button-wrapper{ 
 
z-index:1; 
 
    padding-left:10px; 
 
}
<div class="switch"> 
 
\t \t \t \t \t \t <div class="button-wrapper"><a type="button" class="btn"><img src="http://toptix.com/wp-content/plugins/codecanyon-5586825-image-map-hotspot-wordpress-plugin-v1.2.5/img/icon1.png" /></a></div> 
 
\t \t \t \t \t \t <div class="pulse-wrapper"><div class="pulse"></div></div> 
 
</div>

如何获取不透明度并将其保留在图像后面?

+2

以外的东西一定要记得用'Z-index'你需要指定的位置。 – cameronjonesweb

+1

就是这样,谢谢@ user1672694 – L0ckz0r

+0

很高兴我能帮上忙。我已经发布我的评论作为答案了。 – cameronjonesweb

回答