2016-07-14 65 views
0

我在悬停图形图像时创建弹跳效果的关键帧。我有一切正常工作,但一旦动画完成..图标消失。使用CSS3关键帧

我知道它与电子邮件中设置的translateY属性有关,并且在课堂上链接。

悬停时,我尝试添加最终平移Y属性,但一切都变得出问题......

模块动画HTML

<div class="team-container"> 
     <figure> 
      <div class="circle-item"> 
      <img class="member-image" src="http://sandbox.techgrayscale.com/wp-content/uploads/2016/07/member-image-blank.png"> 
      <div class="image-cover"> 
      </div> 
       <div class="icons"> 
       <a class="email" href="#"><img src="http://sandbox.techgrayscale.com/wp-content/themes/TGSnew/assets/images/email-icon.png"></a> 
       <a class="linkedin" href="#"><img src="http://sandbox.techgrayscale.com/wp-content/themes/TGSnew/assets/images/linkedin-icon.png"></a> 
       </div> 
      <!--end image cover --> 
      </div> 
      <!--end circle item --> 
     </figure> 
     </div> 

图标CSS

.tgs-team figure .circle-item .icons { 
    text-align: center; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 100%; 
} 
.tgs-team figure .circle-item .icons:after { 
    content: ''; 
    width: 1px; 
    height: 0; 
    position: absolute; 
    background-color: #fff; 
    left: 50%; 
    bottom: -50%; 
    transition: height .3s linear; 
} 
.tgs-team figure .circle-item .icons a { 
    display: inline-block; 
} 
.tgs-team figure .circle-item .icons .email { 
    margin-right: 20px; 
    transform: translateY(120px); 
} 
.tgs-team figure .circle-item .icons .linkedin { 
    margin-left: 20px; 
    transform: translateY(120px); 
} 

关键帧CSS

@keyframes iconBounce { 
    0% { 
    transform: translateY(120px); 
    opacity: 0; 
    } 
    50% { 
    transform: translateY(0px); 
    opacity: 1; 
    } 
    75% { 
    transform: translateY(-10px); 
    } 
    100% { 
    transform: translateY(0px); 
    } 
} 

悬停CSS:

.tgs-team figure:hover .image-cover { 
    transform: translateY(0); 
    transition: transform .3s ease-out; 
    } 
    .tgs-team figure:hover .icons:after { 
    height: 88px; 
    } 
    .tgs-team figure:hover .icons .email { 
    animation: iconBounce .40s linear .1s; 
    } 
    .tgs-team figure:hover .icons .linkedin { 
    animation: iconBounce .40s linear .2s; 
    } 
    .tgs-team .member-info .name { 
    font-size: 1.875rem; 
    } 
    .tgs-team .member-info .position { 
    font-weight: 100; 
    } 
} 

Codepen

我就如何得到这个工作损失....我需要的图标没有出现,直到悬停的关键帧将它们放入并保持在那里,直到用户悬停在图形上。

回答

0

添加转发当调用动画时。

更新悬停CSS

.tgs-team figure:hover .image-cover { 
    transform: translateY(0); 
    transition: transform .3s ease-out; 
    } 
    .tgs-team figure:hover .icons:after { 
    height: 88px; 
    } 
    .tgs-team figure:hover .icons .email { 
    animation: iconBounce .40s linear .1s forwards; 
    } 
    .tgs-team figure:hover .icons .linkedin { 
    animation: iconBounce .40s linear .2s forwards; 
    } 
    .tgs-team .member-info .name { 
    font-size: 1.875rem; 
    } 
    .tgs-team .member-info .position { 
    font-weight: 100; 
    } 
} 

默认情况下,关键帧循环回来的时候完成。 Forwards是动画填充属性来防止这种情况。

您可以在这里了解更多:

http://www.w3schools.com/cssref/css3_pr_animation-fill-mode.asp

+0

谢谢!添加前锋完美运作。 – BrandenTGS