Joel B Joel B - 6 months ago 13
CSS Question

Any idea how to add this sinking hover effect to an image/link?

Arrow(custom icon) I am trying to animate

I've created an icon image of an arrow that is also a link. It is on top of a background image. When the mouse hovers over the arrow I'd like to create a "sink" effect similar to the one found in the 2d transitions section here. How can this be done?

My CSS/HTML thus far:



body {
padding: 0;
margin: 0;
}
header {
height: 100vh;
}
.content {
height: 150vh;
}
img#bg {
z-index: -100;
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: 100%;
/* Set up positioning */
position: relative;
top: 0;
left: 0;
}
img#arrow {
position: absolute;
bottom: 50;
left: 45.5%;
}
h1#title {
font-size: 20px;
font-family: arial;
margin-top: 2.5em;
text-align: center;
color: yellow;
}

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Tinker Time</title>
</head>

<body>
<header>
<img src="assets/building2.jpg" id="bg" alt="" />
<a href="#anchor">
<img src="assets/arrow.png" id="arrow" alt="" />
</a>
</header>

<div class="content">
<a name="anchor"></a>
<h1>Team Members, About us, Blog</h1>
</div>
</body>




Answer

The hover code that's part of this lib should still work with an image, heres a working example with a random avatar icon:

/* Sink */
.hvr-sink {
  display: inline-block;
  vertical-align: middle;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.hvr-sink:hover, .hvr-sink:focus, .hvr-sink:active {
  -webkit-transform: translateY(8px);
  transform: translateY(8px);
<!DOCTYPE html>
<html>
<head>

</head>
<body>

<img class="hvr-sink" src="https://www.gravatar.com/avatar/6fce102dc34236cd4e485c69d7293ee9?s=32&d=identicon&r=PG"></img>
<br>

</body>
</html>