Troubleshooting a problem with CSS styling in a jQuery bounce effect

In my current project, I am experimenting with creating a unique 'hovering' link. When the user hovers over an image and then moves the mouse away, I want the link to 'jump' back instead of using jQuery animation.

+-----------+
|  I        |
|   M       |
|     A     |    <-- image (acts as a link)
|      G    |  
|        E  |
+-----------+

 ___________    <-- shadow effect

So far, I have implemented a CSS hover effect along with a ::after CSS system to create a shadow effect. The intention is to lift the image slightly, shrink the width of the shadow, and lighten the shadow, which somewhat works.

Now, I am attempting to incorporate a JQuery 'Bounce' when the mouse exits the link. Unfortunately, due to conflicts with the CSS transition, the bounce effect doesn't function properly.

Another challenge I face is making the setup dynamic to accommodate different-sized images used as links across the page width. I am currently trying to link the parent's width with the shadow's width, but this approach has some issues in implementation.

After completion, my links may resemble something like this:

                          +------------+
+-----------+             |            |
|           |             |            |
|           |             |            |   +---+
|           |   +---+     |            |   |   |
|           |   |   |     |            |   +---+
+-----------+   +---+     +------------+

_____________   _____     ______________     _

                                             ^
                                             |
                                          hovered

This is the current JQuery code I am using:

 $(".topMenuImg").mouseout(function () {
        $(this).effect("bounce", { times: 3 }, 'normal');
        }, function () {
            $(this).effect("bounce", { times: 3 }, 'normal');
          });

You can view the actual CSS being used here.

Integrating the JQuery is causing disruptions, as seen here.


I welcome any comments, suggestions, or clarifications on this matter.

The following picture demonstrates the current 'hover' effect:

Answer №1

Perhaps a solution similar to this could work

 $(".topMenuImg").mouseout(function() {
   $(this).find('.myImg').stop().effect("bounce", {
     direction: 'down',
     times: 3
   }, 400);

 });
.topMenuImg {
  float: left;
  margin-left: 0.25%;
  transition: 0.2s;
  position: relative;
  display: table-cell;
  height: 80%;
  width: 7.5%;
  z-index: 10;
}
.topMenuImg:hover {
  -moz-transform: translate(0, -8px);
  -ms-transform: translate(0, -8px);
  -o-transform: translate(0, -8px);
  -webkit-transform: translate(0, -8px);
  transform: translate(0, -8px);
  -webkit-transform: translateY(-10px);
  transform: translateY(-10px);
}
.topMenuImg:after {
  /*This is the shadow effect*/
  content: '';
  position: absolute;
  bottom: -20%;
  left: 4%;
  z-index: 0;
  width: 90px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0px 10px 0px rgba(14, 14, 14, 0.10);
  transition: 0.4s;
  -moz-transform: translate(0, -8px);
  -ms-transform: translate(0, -8px);
  -o-transform: translate(0, -8px);
  -webkit-transform: translate(0, -8px);
  transform: translate(0, -8px);
  -webkit-transform: translateY(-10px);
  transform: translateY(-10px);
  box-shadow: 0px 10px 0px rgba(14, 14, 14, 0.80);
  padding-left: 80px;
  margin-left: 20px;
}
.topMenuImg:hover:after {
  /*Also shadow effect*/
  content: '';
  position: absolute;
  z-index: 0;
  bottom: 0%;
  left: 8%;
  width: 90px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0px 10px 0px rgba(14, 14, 14, 0.40);
  transform: scale(0.8);
  -moz-transform: translate(0, 4px);
  -ms-transform: translate(0, 4px);
  -o-transform: translate(0, 4px);
  -webkit-transform: translate(0, 4px);
  transform: translate(0, 4px);
  -webkit-transform: translateY(5px);
  transform: translateY(5px);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>

<div class="topMenuImg">
  <img class="myImg" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRM4sZx4tVSdA8DTRHrjZ79l5yVMB5LiwsrhTClLdoxOl8LnsAnmQ" />
</div>

<br />

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

How can I set a minimum height for a table on my website?

Is there a way to make a table that is at least 50px in size, but can still enlarge if there is a lot of text inside? I'm not sure if this even makes sense, but any help would be appreciated. Thank you! ...

What is the best way to rearrange Bootstrap columns for mobile devices?

I have 4 columns displayed like this on desktop, and I want them to rearrange to look like the following on mobile. Do I need custom CSS for this? (I can't post images yet, so here is the link to the image: https://i.sstatic.net/b0gUZ.jpg I've ...

What value does the "left" property default to?

When attempting to change the 'left: 0' property to 'left:none', I found that it did not work. Other properties such as margin and padding do work when overwritten. I aim to find a solution for this problem without altering the origina ...

What is the best way to ensure that this jQuery window has a minimum size?

Recently, I came across a helpful jQuery demo that demonstrated how to create a popup window on my website. For those interested, the demo link can be accessed here: http://jqueryui.com/dialog/#modal-message The design of the window I am aiming to replica ...

Incorporating an SVG with CSS styling from a stylesheet

After exploring various articles and questions on the topic, I am yet to find a definitive solution. I have an external file named icon.svg, and my objective is to utilize it across multiple HTML files with different fill colors and sizes for each instanc ...

Tips for translating an HTML webpage from Arabic to English

I have a bootstrap site with HTML pages but no backend functionality. How can I manually translate from Arabic to English, given that I already have the translations for all content and don't need to rely on translation tools? Is there a way to map Ar ...

Tips on calculating the combined value of price and quantity simultaneously

Greetings, kindly bear with me as my knowledge of JS scripting is quite limited. My expertise lies more in PHP programming. I stumbled upon this neat and straightforward script that calculates the total of product table rows and also provides the grand t ...

Utilizing ionic-scroll for seamless movement and scrolling of a canvas element

I have set up a canvas element with a large image and I want to enable dragging using ionic-scroll. Following the provided example: <ion-scroll zooming="true" direction="xy" style="width: 500px; height: 500px"> <div style="width: 5000px; h ...

What is Causing The Card to Not Expand?

I wanted to enhance my project by incorporating a responsive card template, so I turned to one of the templates on CodePen for help. However, after copying the code into my own platform, I encountered an issue where the card wouldn't expand when click ...

Calling @Url.Action multiple times does not consistently return the same results

It appears that there is a discrepancy related to jQuery/MVC3 that I have yet to figure out. If anyone could shed light on this matter, it would be greatly appreciated. Whenever I invoke an action routine multiple times, the @Url.Action routine generates ...

Django static files reference

sample code snippet tooltip reference navigating to the correct file path FILES: settings.py STATICFILES_DIRS = [ BASE_DIR / "static" , ] base.html {% load static %} How can I properly link my static files in the html line below?... &l ...

Choose the content in the second column

Can anyone help me with CSS selectors? I've been trying to target the second .col_content element in my code to apply a specific background image, but I haven't had any luck so far. Adding a second class would be an easy fix, but I'm curious ...

Displaying the appropriate DIV element based on the value entered by the user

I am encountering some difficulties... I have an <input> field. Depending on the input, one of the various <div> elements should be displayed. For now, it's just a text (e.g. "Your plan contains less than 1500 kcal!"), but later, the div ...

Is there a way to assign innerHTML values to table cells using PHP?

I'm currently building a website that relies on a database to store information. I have created an array to hold the values retrieved from the database, and now I need to populate a table with these values. Each cell in the table has a numerical ID ra ...

How can a button be linked directly to a particular list item?

I currently have a HTML tag within my React application that looks something like this: <ul> <li> Item 1 <button> Delete </button> </li> <li> Item 2 <button> ...

Guide to making a single row beneath two columns using CSS Grid

My goal is to utilize CSS Grid in order to design a blurb layout featuring 2 columns at the top and a full row below. This will allow for an FA Icon and Title, accompanied by a full description below, similar to the image provided. I believe I have succes ...

What are some strategies for disregarding global CSS styles?

I am facing an issue on my html page with a specific div structure. The <div id="container">/* lots of nested html with elements like div, ul, li etc */</div> is causing some trouble in my global css file called style.css. The style. ...

Enable row selection in UI-Grid by clicking on a checkbox with AngularJS

I am a newcomer to angular js and I am looking to have the checkbox automatically selected when clicking on a row to edit that specific cell. I have implemented a cell template to display the checkbox in the UI-grid, but now, when I select a row, the row i ...

Letters are frolicking in varying sizes and designs

Currently, I am encountering a strange issue with the text on my webpage. Some fonts are displaying with completely different shapes and sizes despite using <meta charset="UTF-8"> to ensure font consistency. Unfortunately, this did not resolve the pr ...

Selecting the label "for" will activate both the anchor tag and input tag simultaneously

It seems like I'm having trouble making this work, and it appears to not be possible. That's why I'm reaching out for help... Here is the CSS that is being used: label.btn { cursor:pointer; display:inline-block; } label.btn>inpu ...