Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
How to turn off hover effect after certain amount of time?

I have a hover effect where when the icon image is hovered over, an larger image appears (for clarity). I want this larger image effect to end after three seconds AND still have the hover ability. If the image is moved off of, then came back to; I want the larger image to load for another three seconds. Every time the image is hovered over, the effect would last three seconds.

I have tried CSS animations, transitions, setTimeout and none of them are working like I need. Any help is appreciated. I have a LOT of code on this project, so I will try to only include the relevant parts. Thanks in advance.

I will have the code added to the question, once i figure out what I am doing wrong.

Code for building levels for hover image




#PlayerMarker1 {
  position: absolute;
  left:2%;
  top: 2%;
  z-index: 9;
}

#Player1Final{
  position: absolute;
  left:2%;
  top: 2%;
  z-index: 9;
}

/* Elements for Image load on hover*/

.playerMarker img{
  margin: 0 5px 5px 0;
  }

.playerMarker:hover{
  background-color: transparent;
  }
  
  .playerMarker:hover img{
  border: 1px;
  }
  
  .playerMarker span{ /*CSS for enlarged image*/
  position: absolute;

  padding: 0px;
  left: -1000px;
  /*background-color: black ;*/
  visibility: hidden;
  color: black;
  text-decoration: none;
  }
  
  .playerMarker span img{ /*CSS for enlarged image*/
  border-width: 0;
  padding: 2px;
  }
  
  .playerMarker:hover span{ /*CSS for enlarged image*/
  visibility: visible;
  top: 0;
  left: 100px; /*position where enlarged image should offset horizontally */
  z-index: 50;
  }

Code for defining the images.

<div id="Player1Test">
    <a id="PlayerMarker1" href="#thumb1"><img src="Player Markers/Morty_Icon.png" width="auto" height="auto"/><span><img src="Player Images/Morty_Token.png" /><br /></span></a>
  </div>

This script adds the playerMarker classes to the element I need.

  /* Script to add class to player marker ID items */

   function Player1Function() {
   var Player1FinalTest = document.getElementById("PlayerMarker1");
   Player1FinalTest.classList.add("playerMarker");
   Player1FinalTest.id='Player1Final';
   }
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Seems like css animations to pulse the image would work fine. Run the code snippet to try.

img {
  margin: 25px;
  width: 100px;
  height: auto;
}

img:hover {
  animation: pulse 2s 1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
    }

    50% {
        transform: scale(1.4);
        box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
<h4>Hover the mouse over image<h4>
<img src="https://stackoverflow.design/assets/img/favicons/apple-touch-icon.png">

about 4 years ago · Santiago Trujillo Report

0

Yogi has a good answer using an animation that could be adapted to clearly move your element. I wanted to add an answer manipulating the left and top values using delay.

You are essentially moving a hidden image from off screen onto the screen. Though this feels a bit strange to do, as there may be more clear ways of accomplishing this task, you can immediately move the left into view, and delay moving the top out of view.

A different delay is needed for the hover and for the base element, so it returns to the original position immediately and is available for reuse, but delays moving away on hover.

This might keep in spirit of your current project.

If you have any questions, please ask 🚀

.playerMarker {
  background-color: lightblue;
  --size: 4rem;
  height: var(--size);
  width: var(--size);
}

.playerMarker span { 
  position: absolute;
  padding: 0px;
  top: 0;
  left: -1000px;
  visibility: hidden;
  color: black;
  text-decoration: none;
  
  transition: top 0s;
}
  
.playerMarker span img { 
  border-width: 0;
  padding: 2px;
}
  
.playerMarker:hover span { 
  transition: top 0s 2s;
  visibility: visible;
  top: -1000px;
  left: 100px; 
  z-index: 50;
}
<div class="playerMarker">
  <span>
    <img src="https://stackoverflow.design/assets/img/favicons/apple-touch-icon.png" />
  </span>
</div>

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!