Activating animations in a separate div by hovering over it

I customized my navbar on a personal website, with my name appearing on the left side. I'm experimenting with creating a "wave effect" where hovering over each character triggers an animation. Any suggestions for improving this approach?

Current state of my navbar: https://i.sstatic.net/YZ2Sb.png Picture every letter lifting and descending as you hover across my name.

Snippet from React file:

<Navlink to="/" exact={true} className={styles['title-link']}>
<div className={styles.title}>
        <span className={styles.animate1}>L</span>
        <span className={styles.animate2}>e</span>
        <span className={styles.animate3}>e</span>
        <span> </span>
        <span className={styles.animate4}>R</span>
        <span className={styles.animate5}>e</span>
        <span className={styles.animate6}>n</span>
        <span> </span>
        <span className={styles.animate7}>J</span>
        <span className={styles.animate8}>i</span>
        <span className={styles.animate9}>e</span>
      </div>
</Navlink>

Snippet from SCSS file:

.title-link {
      position: relative;
      right: 275px;
      text-decoration: none;
    }

 .title {
     color: white;
      font-family: 'Cedarville Cursive', cursive;
      text-decoration: none;
     font-size: 30px;
   }

 .title:hover {
      span:first-child {
        animation-delay: 0.11s;
      }
      span:nth-child(2) {
        animation-delay: 0.22s;
      }
      span:nth-child(3) {
        animation-delay: 0.33s;
      }
      span:nth-child(5) {
        animation-delay: 0.44s;
      }
      span:nth-child(6) {
        animation-delay: 0.55s;
      }
      span:nth-child(7) {
        animation-delay: 0.66s;
      }
      span:nth-child(9) {
        animation-delay: 0.77s;
      }
      span:nth-child(10) {
        animation-delay: 0.88s;
      }
      span:nth-child(11) {
        animation-delay: 0.99s;
      }
  }

.animate1, .animate2, .animate3, .animate4, .animate5, .animate6, .animate7, .animate8, .animate9{
  animation-name: bounce;
  animation-duration: 1s;
}

@keyframes bounce {
  0% {
      bottom: 0;
  }
  50% {
      bottom: 5px;
  }
  100% {
      bottom: 0;
  }
}

Answer №1

I successfully implemented your example using CSS (I couldn't find a fiddle host that allowed SCSS).

The issue seemed to be with using spans - they don't seem to animate inline elements. So I opted for a div with display: inline-block

Check out the working example here

<div id="title">
  <div class="animate1">L</div>
  <div class="animate2">e</div>
  <div class="animate3">e</div>
  <div class="animate4">R</div>
  <div class="animate5">e</div>
  <div class="animate6">n</div>
  <div class="animate7">J</div>
  <div class="animate8">i</div>
  <div class="animate9">e</div>
</div>
@-webkit-keyframes bounce {

  0%,
  100% {
    -webkit-transform: translateY(0);
  }

  50% {
    -webkit-transform: translateY(-5px);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

#title:hover > div:first-child {
  -webkit-animation-name: bounce;
  animation-name: bounce;
  animation-duration: 1s;
}

#title:hover > div:nth-child(2) {
  -webkit-animation-name: bounce;
  animation-name: bounce;
  animation-duration: 1s;
  animation-delay: 0.11s;
}
...
<!-- More CSS animations follow -->
...
#title {
  color: black;
  font-family: 'Cedarville Cursive', cursive;
  text-decoration: none;
  font-size: 30px;
}

#title > div {
  display: inline-block;
}

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

Creating divs that adapt to different screen sizes without relying on flexbox

Currently, I am in the process of developing a chat interface where the viewport height is set to 100vh. The layout consists of a header/navbar, a "main content" section, and a footer housing the input field (you can view the code here) The way I have str ...

Tips for managing the creation of dynamic Bootstrap cards using jQuery

I am embarking on the creation of an entertaining game where users can input their name and email address. Upon clicking the "Add" button, a new card will be generated containing a form with checkboxes labeled "One" and "Two". Depending on the selection of ...

Constantly encountering errors instead of obtaining results with each AJAX call

I have a button on my webpage that triggers a JavaScript function I've created. I have successfully debugged into this function. However, whenever the function reaches the AJAX part, it always returns with an error message alert. I aim for the AJAX ...

Dividing a string starting from the first appearance of a specific character

I need assistance with parsing multiple lines of text found in log files following this specific format: topic, the message part, contains occasional commas. Is there a method to separate the string starting from the first comma so that I can store the t ...

halt execution of npm test and erase any printed content

When I run npm test on my React project, it runs unit tests using jest and react testing library. The test logs (including console log lines added for debugging) are printed to the screen but get deleted after running the tests. It seems like the logs are ...

Modifying a single element within a class with Jquery

Is it possible to create a stack of pages on a website using JQuery? I found this image that shows what I'm trying to achieve: image. Instead of applying ID css for each page, I'd like to use JQuery. While researching similar questions, I came ac ...

How to dynamically insert a new row below a specific row with a sliding animation in jQuery

My task is to create a tree-like table structure where clicking on a specific row will reveal and add new rows below it. Specifically, I am designing the Category and SubCategory structure. Currently, I can append rows after a specified row but am struggl ...

Showing content based on the route - Angular

I'm struggling to hide the navbar based on a specific route in my application. I have managed to subscribe to the route changes, but I am having difficulty changing the display property accordingly. Here is what I have so far: export class AppCompo ...

Guide on parsing a JSON document using Javascript

In my possession is a JSON file with the following data: [ { “name”: “Joshia \”Placement\” Fonz”, “color”: “white” }, { "name": “Trin Brin”, “color”: “black” }, { “name”: “Su Et ...

Scroll bar displayed on a non-editable text box

The TextArea is currently set to readonly mode using "ng-readonly," which is causing the scrollbar-thumb not to appear. It's important to note that I am not utilizing webkit in this scenario. Below is the HTML code being used: <textarea dataitemfq ...

What is the method to transform a string that represents an array of objects into an actual array of objects in javascript?

My data consists of an array of objects in the form of a string like this "[{'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}, {'key1': 'val1', 'key2': 'val2 ...

Functionality of Sidebar Navigation malfunctioning with Next.js framework

I'm attempting to implement a sidebar using Next.js, but the code is currently in React format. I tried copying it and converting it to Next.js, but the links in the navigation aren't working. Additionally, I'm having trouble displaying the ...

What are the steps to configure an option date for Yesterday, Today, and Tomorrow?

I have been working on setting options for dates like yesterday, today, and tomorrow. I have implemented the following code which is functioning properly, but it is not displaying yesterday's date. I want today's date to be selected and also disp ...

Configuring Axios header in Java backend based on the value stored in the express session

I am currently working on a frontend app using node.js express for server-side rendering. This app calls java backend endpoints and I use Axios to make the requests. A specific header named "agent-id" needs to be set in every request that is sent from expr ...

Converting this Jquery function to vanilla Javascript

I'm currently encountering difficulties reworking this slideshow feature using Javascript. Due to certain project limitations, I am required to switch back to pure JS. document.querySelectorAll(".fadein img:not(:first-child)").forEach(function(element ...

Enhance Your Images: Creating Stunning Colored Overlay Effects using HTML and CSS

I'm currently working on implementing an overlay effect for images on a webpage. The idea is that when the cursor hovers over an image, it will change color slightly. However, I'm facing some issues and the desired effect is not reflecting. How c ...

ReactJS encountered an error: _this3.onDismissID is not defined as a function

My goal is to retrieve the latest news related to a specific search term from a website, showcase them, and provide a dismiss button next to each news item for users to easily remove them if desired. Here's a snippet of the code I'm using: import ...

What is the typical response time for a request using javascript axios?

In my current application, I am fetching data from an API and everything is functioning correctly. However, I am interested in determining the duration of each request in milliseconds. To achieve this, I implemented interceptors using axios. The challenge ...

When the dropdown form options in HTML are clicked, they appear disproportionately large compared to the initial select box

Sorry if my wording is a bit off, I'm still relatively new to working with CSS and HTML. I've encountered an issue where the dropdown options appear much larger than the select box itself when clicked. I can't seem to figure out how to fix i ...

Instructions on adjusting the image size within a MUI Card

import { Card, CardActionArea, CardContent, CardMedia, Typography, } from "@mui/material"; import React from "react"; import { styled } from "@mui/material/styles"; const CardImage = styled("div")(({ theme ...