Will
Will

Reputation: 97

Hover animation bounce

I am trying to make it so that the H2 and the span text has a bit of a bounce effect towards the end of the hover animation I've created. What I am trying to do can be seen in the following example. Just to be clear in that example, SCSS is being used. I am not using SCSS so I am not 100% sure what I am trying to do is possible with just plain CSS but I sure hope it is because that is what I am using for my project. So the code below shows you what I was able to do. The H2 and span text have a basic start point and end point animation on hover. I want it to have a little bounce towards the end(like in the linked example I shared) something I feel I need to add key-frames to in order to achieve. But I don't know if its even possible to add a key-frame animation on hover especially if I want it to animate back to its original position on mouse out. Am I wrong about this? I appreciate any solutions you guys might have. thank you.

body {
  background-color: black;
}

.featured-list li {
  display: inline-block;
  margin-right: .8%;
}

.featured-list a {
  display: block;
}

.featured-list {
  text-align: center;
  padding: 0;
  margin: 0 auto;
}

a.feature-img img {
  width: 425px;
  border-radius: 5px;
  transition: .2s linear;
}

a.feature-img {
  text-align: center;
}


.f-cta, .f-img-content h2 {
  font-family: 'Abel',Helvetica,Arial,Lucida,sans-serif;
  font-weight: 100;
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
}

.f-img-content h2 {
  color: #fff;
  top: -60%;
  transition: .2s linear;
}

.f-cta {
  background: #fff;
  width: 50%;
  border-radius: 3px;
  padding: 7px;
  color: #000;
  top: 120%;
  font-size: 1.3em;
  transition: .2s linear;
}

.f-img-content {
  position: relative;
  text-align: center;
  overflow: hidden;
}

a.feature-img:hover img {
  opacity: .6;
}

a.feature-img:hover h2 {
  transform: translateY(1065%);
}

a.feature-img:hover span.f-cta {
  transform: translateY(-600%);
}
<ul class="featured-list">
      <li><a href="#" class="feature-img">
        <div class="f-img-content">
          <img src="https://i.imgur.com/EENJU66.gif">
          <h2>Lorem Ipsum project title</h2>
          <span class="f-cta">View Project</span>
        </div>   
      </a></li>
      <!--li><a href="#" class="feature-img">
      <img src="https://i.imgur.com/EENJU66.gif">
      </a></li>
      <li><a href="#" class="feature-img">
      <img src="https://i.imgur.com/EENJU66.gif">
      </a></li>
      <li><a href="#" class="feature-img">
      <img src="https://i.imgur.com/EENJU66.gif">
      </a></li-->
    </ul>

Upvotes: 0

Views: 1811

Answers (1)

dako
dako

Reputation: 1173

You just need cubic-bezier transitions.

Something like this one - https://easings.net/#easeInOutBack Or the same as this from your example:

transition:all .3s cubic-bezier(.3, 0, 0, 1.3);

Just play around with it :)

Upvotes: 1

Related Questions