2016-07-14 98 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