简体   繁体   English

使用CSS3关键帧

[英]Using CSS3 Keyframes

I'm creating keyframes for a bounce effect when hovering a figure image. 我正在将人物图像悬停时创建反弹效果的关键帧。 I have everything working correctly but once the animation is done.. the icons disappear. 我一切正常,但动画制作完成后,图标消失了。

I know it has to do with the translateY property set on the email and linked in class. 我知道这与在电子邮件上设置并在类中链接的translateY属性有关。

On hover, I tried adding the final translateY property but everything becomes glitchy... 悬停时,我尝试添加最终的translateY属性,但是所有内容都出现故障...

Module Animation HTML 模块动画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>

Icons CSS 图标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);
}

Keyframe CSS 关键帧CSS

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

Hover CSS: 悬停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 码笔

I'm at a loss on how to get this to work....I need the icons to not appear until the keyframes on hover bring them in and stay there till the user hovers off the figure. 我对如何使它工作不知所措。...我需要图标不出现,直到悬停的关键帧将它们带入并停留在那里,直到用户将鼠标悬停在图形上为止。

Add forwards when calling the animaiton. 调用动画时添加前

Updated Hover CSS 更新了悬停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;
  }
}

By default, keyframes loop back when complete. 默认情况下,关键帧完成后会循环返回。 Forwards is the animation-fill-property to prevent this. Forwards是防止这种情况的动画填充属性。

You can learn more here: 您可以在此处了解更多信息:

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

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

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