Do you have any tips on incorporating a sinking hover effect to an image or link?

Custom Arrow Icon I Want to Add Animation To

I have designed an arrow icon image that functions as a link. It is positioned on top of a background image. When the user hovers over the arrow, I would like to implement a "sink" effect similar to the examples provided in the 2D transitions section here. How can I achieve this effect?

Here is my current CSS/HTML code for reference:

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 №1

If you're wondering whether the hover code in this library can still function with an image, check out this live demonstration featuring 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>

Answer №2

If you want to achieve a cool hover effect using the hover.css library, follow these steps:

Start by including the hover.css stylesheet in your HTML file like this:

<link rel="stylesheet" type="text/css" href="css/hover.css">

Then, insert the following code snippet:

<img src="assets/arrow.png" id="arrow" alt="" class="hvr-sink" />

Answer №3

Check out this simplified version - could potentially be represented as an image.

If simplicity is your goal, there's no need for a fancy and complicated library!

.red_box {
  display: block;
  width: 100px;
  height: 100px;
  background: red;
  transition: all 0.5s ease;
}
.red_box:hover {
  transform: translateY(16px);
}
<div class="red_box"></div>

Answer №4

Straightforward:

  1. Integrate hover.css into your HTML document,
  2. Assign the hvr-sink class to your arrow image.

For instance:

    <body>
    <header>
    <img src="assets/building2.png" id="bg" alt="" />
    <a href="#anchor">
      <img src="assets/arrow.png" class="hvr-sink" id="arrow" alt="" />
    </a>
  </header>
  <div class="content">
       <a name="anchor"></a>
        <h1>Team Members, About us, Blog</h1>
      </div>
   </body>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Python Selenium cannot locate button within an iframe

click here for imageI am trying to interact with the "바카라 멀티플레이" button located at the center of the website. Even after switching into an iframe, I am unable to detect the button. How can I achieve this? from selenium import webdriver im ...

Struggling to align the header of a column to the center in a mat-table that is sortable?

I am working with a mat-table that has a sortable column similar to the example shown here, but I am having trouble centering the column headers using my CSS file. Interestingly enough, I am able to achieve this when making changes in the browser debugger! ...

Discover the procedure to alter date formats in MongoDB

I recently created a MongoDB collection using Node.js with the following code: var mongoose = require('mongoose'); var TTTUsersSchema = new mongoose.Schema({ username: String, password:String, active: Boolean, created_at: { type: Dat ...

Error: Uncaught TypeError - The function indexOf is not defined for e.target.className at the mouseup event in HTMLDocument (translator.js:433) within the angular

Upon clicking on an SVG to edit my data in a modal bootstrap, I encountered the following error: Uncaught TypeError: e.target.className.indexOf is not a function at HTMLDocument.mouseup (translator.js:433) This is my SVG code: <svg data-dismiss ...

Setting up Visual Studio Code for debugging HTML and JavaScript code

Struggling to troubleshoot some HTML/JavaScript using VSCode. After installing the Chrome debugger extension and configuring the launch.json as follows: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of ex ...

Generate responsive elements using Bootstrap dynamically

I'm having success dynamically generating bootstrap elements in my project, except for creating a drop-down menu. ColdFusion is the language I am using to implement these div elements: <div class="panel panel-primary"><div class="panel-head ...

adjusting the dimensions of images to ensure uniformity in size

After many attempts, I am still struggling to resize my image. Can anyone offer assistance? I want all images to have the same dimensions. Here is the HTML code: <link href='https://fonts.googleapis.com/css?family=Indie+Flower' rel='sty ...

Can cookies operate on a local server?

Similar Question: Cookies on localhost with explicit domain Here is the code snippet that I am using after the user has logged in: setcookie("user",$entered_username, time()+(60*60*5)); setcookie("password",$entered_password, time()+(60*60*5)); ...

Tips on solving the Navigation bar burger problem with HTML and CSS

## I am having trouble making my navigation bar responsive using HTML and CSS as the navigation burger does not appear in mobile view ## To take a look at my code on jsfiddle, click here: [jsfiddle] (https://jsfiddle.net/abhishekpakhare/nxcdso7k/1/ ...

Switching the default z-index for child elements within an HTML container

According to the specification, elements are typically drawn "in tree order" for in-flow, non-positioned elements of similar block level or float status and identical z-index. This means that elements declared last in the HTML markup appear on top. But wha ...

The jQuery function may encounter issues when trying to target elements within an appended HTML form

I am encountering a couple of issues. I have 2 separate JQuery functions, one for appending content and the other for displaying the selected file's name. FUNCTION 1 <script> jQuery( document ).ready(function( $ ) { $("input[name ...

Can you identify the programming language used in this code snippet? - {"html":"<section class="page">

I've been approached to assist with a friend's company website since the original developer seems to have disappeared. Apologies if this question is too basic for this forum, and please forgive me if I am not in the right place to ask it. The m ...

Connect an existing function to JQuery animation

There is a function in place that changes the background image of a vertical website when a navigation menu item is clicked. <script type="text/javascript"> $(function() { $('a.panel-home').click(function(){ $("#bgimg").attr(' ...

Running JavaScript code along with HTML elements extracted from a jQuery ajax callback

Alternatively, not exactly "executing," but rather updating a pre-existing function with a function returned in the response. Step 1 I have an HTML5 page detailing a specific location. The server-side includes a ColdFusion file called "MapFunction.cfm" ...

Use column formatting for the table's body section

I have written the code below in HTML to create a table. I am looking to apply a specific style to the table body elements in a column that has been assigned a CSS class, while excluding the header columns from this style application. As an example, I hav ...

Determine the length of the content within an HTML container that has

I am attempting to retrieve the length of the container's content in HTML dynamically. However, I am only receiving the object instead of the desired result. <script> $(document).ready(function (e) { var adsense_box_len = $(&apo ...

Creating a single-level menu with Bootstrap using nested angular ng-repeat

I am currently working on developing a single level menu using bootstrap and angularJS. The menu is successfully functioning with JavaScript and HTML when the <li> element is dynamically created. Now, I am attempting to integrate AngularJS into the ...

Apply a specific style conditionally using Angular's ng-repeat directive

Currently, I am utilizing ng-repeat to iterate through a list of divs and manually adding items to the JSON that is rendering these divs. My goal is to position the last div that I add in the JSON at the location where the mouse cursor is, while keeping th ...

What is the best way to implement horizontal content scrolling when an arrow is tapped in mobile view?

I recently created a JS Fiddle that seems to be working fine on desktop, but in mobile view, the square boxes have horizontal scrolling. Here are the CSS codes I used for this particular issue: @media only screen and (max-width: 767px) { .product-all-con ...

Proper Alignment of Div Elements

Just starting out with coding and currently practicing display and positioning. I've created a webpage with multiple divs containing the same content, displayed in a vertical scroll order. Now, I'm looking to position these divs side by side in r ...