Is there a way to make this animation activate when the entire area in front of the link is hovered over or tapped?

I am working on an animation that needs to run behind a link. Here is an example: https://codepen.io/ehbehr/pen/KKNbOvN and below is the HTML and CSS:

*, *:before, *:after {
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  width: 100%;
  height: 100vh;
}

.container > div {
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrap {
  position: relative;
  width: 100%;
  height: 100vh;
  }


.linky-thing {
  width: auto;
 display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.thankyou {
  color: magenta;
  text-decoration: none;
  white-space: nowrap;
  font-size: 2em;
  font-family: arial;
}

.pulser {
  position: absolute;
  display: block;
  width: inherit;
  padding-top: 20px;
  height: 2em;
  z-index: -1;
}
.pulser p {
  position: absolute;
  margin: 0;
  padding: 0;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  z-index: -1;
}

.pulser p:before {
 content: '';
  position: absolute;
  height: 15px;
  width: 15px;
  top: 0%;
  left: 0%;
  bottom: 0%;
  right: 0%;
  border-radius: 50%;
  border: 2px solid #2cfa1f;
    background-size: 100%;
  border-radius: 50%;
  opacity: 0;
/*}


.pulser p:hover:before {*/
  animation-name: pulse;
  animation-duration: 1.5s;
  animation-delay: calc(var(--animation-order)/.33 * 100ms);
  animation-fill-mode: both;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes pulse {
  0% {
        transform: scale(0);
    }
  
  33% {
    opacity: 1;
    }

    100% {
        transform: scale(2.7);
    opacity: 0;
    }
}
<div class="container">
  <div class="wrap">
  <div class="linky-thing"><a class="thankyou" href="https://wikipedia.org">lorum ipsum dolor sit amet colotum ecvo</a>
   <div class="pulser">
    <p style="--animation-order: 3;" />
    <p style="--animation-order: 2;" />
    <p style="--animation-order: 1;" />
    </div>
    </div>      
  </div>
</div>

There are some challenges I have encountered:

  1. When using the :before pseudo-element, I can make it animate but only when I position it in front of the text and not anywhere on the link behind it. I want the animation to be triggered no matter where the cursor is placed on the text. Additionally, I want it to animate behind the text link. Placing it under the link does not trigger the animation on hover.

  2. The animation, borrowed from https://codepen.io/dbenmore/pen/zVxrpB, works as expected when running 3 staggered instances, however, it only works in the :before state and not in the :hover:before state where it only runs once. How can I make it iterate all three times in the :hover:before state? (Using a blurry png as a workaround is not ideal).

  3. For added interactivity, I would like the animation to originate from wherever the cursor lands on the text link. This might require some JavaScript implementation, as I have multiple links on the page where this animation should apply. The page is a "thank you" page listing sites that helped me build my website.

Thank you in advance.

Answer №1

To activate the animation on hover of the link text, the hover event needs to be detected on the "linky-thing" element, not on the pulser itself.

This code snippet has been updated from:

.pulser p:hover:before

to:

.linky-thing:hover .pulser p:before

*, *:before, *:after {
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  width: 100%;
  height: 100vh;
}

.container > div {
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrap {
  position: relative;
  width: 100%;
  height: 100vh;
}


.linky-thing {
  width: auto;
 display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.thankyou {
  color: magenta;
  text-decoration: none;
  white-space: nowrap;
  font-size: 2em;
  font-family: arial;
}

.pulser {
  position: absolute;
  display: block;
  width: inherit;
  padding-top: 20px;
  height: 2em;
  z-index: -1;
}
.pulser p {
  position: absolute;
  margin: 0;
  ...

.pulser p:before {
 content: '';
  position: absolute;
  height: 15px;
  width: 15px;
  ...

.linky-thing:hover .pulser p:before {
  animation-name: pulse;
  animation-duration: 1.5s;
  animation-delay: calc(var(--animation-order)/.33 * 100ms);
  animation-fill-mode: both;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0);
  }
  
  33% {
    opacity: 1;
  }

  100% {
    transform: scale(2.7);
    opacity: 0;
  }
}
<div class="container">
  <div class="wrap">
  <div class="linky-thing"><a class="thankyou" href="https://wikipedia.org">lorum ipsum dolor sit amet colotum ecvo</a>
   <div class="pulser">
    <p style="--animation-order: 3;" />
    <p style="--animation-order: 2;" />
    <p style="--animation-order: 1;" />
    </div>
    </div>      
  </div>
</div>>

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

Selected value is not displayed in the textbox when using autocomplete feature

---Ajax---- An issue has arisen with the autocomplete feature. While typing "wi" (for example, wipro), the drop-down list appears as expected. However, if only "wi" is selected in the text box, $(document).ready(function () { $("#company_name").key ...

Nested divs with independent scrolling capabilities

I am interested in developing a gantt chart that displays days, months, and years at the top with tasks listed below. Here is my progress so far: https://i.stack.imgur.com/tr5y4.png In the image above, the scroll-x functionality works on everything incl ...

What is the best way to access an element from an array nested within an object in Firestore?

In my Firestore database, the structure includes multiple arrays within the "reserved items" object. Each array contains more than one element. How can I extract the "returnDate" element from every single array within the object? ...

Boost Engagement with the jQuery PHP MySQL Like Feature

Seeking assistance in creating a like button with PHP, MySQL, and jQuery. I'm encountering an error but unable to pinpoint its source. Can anyone provide guidance? The project involves two pages: index.php & callback.php INDEX $k = 1; //POST ID $n ...

Navigating to a new page by clicking a button

I am trying to redirect to a different web page when a button is clicked. Below is the code snippet I am working with: JavaScript code snippet: app.controller('myCtrl', ['$scope', '$location', function($scope, $location) { ...

To create a distinctive design, the HTML5 wrapper will specifically enclose the Header element

After using a border, I discovered that my wrapper is only wrapping the header and not extending down to the footer. Can anyone offer some guidance on how to wrap the entire content from the header to the footer? I've come across suggestions to speci ...

Sending data from a child component to its parent counterpart

A component called cartComponent has a data property named cartCount which increases every time a new item is added to the cart. I want to utilize this value to update another value in the template that is not part of the component. Is it achievable? Bel ...

Ways to restrict the content div JSON display to only three items

Is it possible to limit the display of items from JSON in the content div to just three? The current code displays all downloaded items, but I want only 3 divs to be returned. <div id="p"></div> $.getJSON('element.json', function(d ...

Modifying the information depending on the option chosen from the dropdown menu using angularJS

I have a dropdown menu where I can choose between two options, and when selected, the corresponding data is displayed. However, I would like to display the data that is inside a div tag instead. Check out this Fiddle Demo HTML: <div ng-controller="Ct ...

Storing content from external files in Angular 1.x templateCache

I am currently utilizing the Angular templateCache, following the example set in Angular's documentation. var myApp = angular.module('myApp', []); myApp.run(function($templateCache) { $templateCache.put('templateId.html', ' ...

Optimizing CSS across various pages and screens sizes with critical importance

My CSS file is in need of optimization for quicker loading times. It contains numerous components utilized across various pages (such as the start page, category pages, and detail pages) on different screen sizes (mobile, tablet, desktop). Manual optimizat ...

Utilize a fluid AJAX endpoint for the Vue Select2 encapsulated component

I have customized the Wrapper Component Example based on VueJS documentation by adding the AJAX data source feature. You can view my modified code here. My goal is to dynamically set the ajax url property of my select2 component, like this: <select2 :o ...

The jQuery mouseout functionality seems to be malfunctioning and not responding as expected

I am currently developing a slider that displays details when the mouse hovers over the logo, and hides the details when the mouse moves away from the parent div. jQuery('.st_inner img').mouseover(function() { jQuery(this).parent().siblings( ...

What is the best way to horizontally align Font Awesome icons in the center?

In my table, I have a Font Awesome icon that I'm trying to align left with text and center the icons. I attempted to center the <i> element but it didn't work as expected: Here is the HTML code: <td><i class="icon-ok"></i&g ...

What could be causing this `even` function to malfunction when utilizing getElementById?

Need assistance with utilizing document.getElementById? Let's take a look at this code snippet: function even() for (i = 0; i < 10; i++) { if (i % 2 == 0) { alert(i); } } document.getElementById("even").innerHTML = i + &apos ...

Tips for linking to a page and dynamically adding a class to the body after it has been fully loaded

I've been working on a template that includes a blog.html file featuring various layouts: full-width layout 2 column layout 3 column layout 4 column layout I've customized the blog.html so that when specific classes are added to the body tag, ...

Access to private members is restricted when redefining a class method

After defining a private member with #, attempting to redefine a member that utilizes this private member will result in the inability to access it: class Foo { #secret = "Keyboard Cat"; method() { console.log(this.#secret); } } ...

Converting HTML and CSS into a PDF using JavaScript

I am on the lookout for libraries that can cater to my specific needs, as I haven't found one that fits perfectly yet. My setup involves Node.js on Express.js for the backend, and html/css/js for the front-end. Browser support includes IE8 and up, chr ...

Grunt is designed to generate a single file, instead of producing multiple files

I have a simple Gruntfile that is designed to read a plain text file line by line and create an html file of the same name for each line. However, it seems to only work with one line in the file at a time, not multiple lines. Here is the console output wh ...

Troubleshooting issue: AngularJS - Updating variables in view without utilizing scope

I seem to be facing an issue with my Angular code. Some variables are not updating after their values have been changed. While my header updates correctly, the footer remains stuck with its initial values. Here is a snippet of my code: <body> < ...