The animation in CSS seems to be malfunctioning, but strangely enough, the exact same code works elsewhere

Recently, I encountered a strange issue with my project. An animation effect that was working perfectly fine suddenly stopped working when I opened the project. To troubleshoot, I downloaded the same project from my GitHub repository and found that the animation worked without any problems.

I decided to copy the code from GitHub and paste it into the project that had the issue, but unfortunately, the animation still did not work. I even tried restarting the computer, but the problem persisted in both Google Chrome and Safari browsers.

The code snippet causing the animation issue is as follows:

.cv img {
  position: relative;
  top: -12rem;
  left: 30rem;
  width: 15rem;
  cursor: pointer;
  animation: click 1s infinite;
}

@keyframes click {
  0% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1);
  }
}

Interestingly, the code from GitHub which works looks identical to the problematic one. This has left me puzzled as to why there is a difference in behavior between the two versions.

Here is the HTML code snippet related to the animation:

<div class="hero-image">
  <div class="human"><img alt="human" src="/img/photo.png" /></div>
  <div class="skills intro">
    <img alt="skills" src="/img/js.png" />
    <img alt="skills" src="/img/react.png" />
    <img alt="skills" src="/img/c2.png" />
    <img alt="skills" src="/img/html2.png" />
    <img alt="skills" src="/img/css2.png" />
    <img alt="skills" src="/img/python.png" />
  </div>

  <a
    href="/resume.pdf"
    class="cv"
    target="_blank"
    rel="noopener noreferrer"
    ><img alt="c" src="/img/cv2.png"
  /></a>
</div>

Answer №1

It appears that both of your code snippets are functioning properly, indicating there may be another underlying issue causing the problem you're experiencing. Use your developer tools to inspect the element and verify if the CSS styles are correctly applied.

/*
.cv img {
  position: relative;
  top: -12rem;
  left: 30rem;
  width: 15rem;
  cursor: pointer;
  animation: click 1s infinite;
}

@keyframes click {
  0% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1);
  }
}

*/




.cv img {
  position: relative;
  top: -12rem;
  left: 30rem;
  width: 15rem;
  cursor: pointer;
  animation: click 1s infinite;
}

@keyframes click {
  0% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1);
  }
}
<div class="hero-image">
  <div class="human"><img alt="human" src="/img/photo.png" /></div>
  <div class="skills intro">
    <img alt="skills" src="https://via.placeholder.com/150" />
    <img alt="skills" src="https://via.placeholder.com/150g" />
    <img alt="skills" src="https://via.placeholder.com/150" />
    <img alt="skills" src="https://via.placeholder.com/150g" />
    <img alt="skills" src="https://via.placeholder.com/150" />
    <img alt="skills" src="https://via.placeholder.com/150" />
  </div>

  <a href="/resume.pdf" class="cv" target="_blank" rel="noopener noreferrer"><img alt="c" src="https://via.placeholder.com/150" /></a>
</div>

Although one version is commented out in the CSS snippet, it seems that toggling between them does not affect the functionality. The issue persists regardless of which one is activated.

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 you easily ensure your React web app is responsive?

As I delve into building a web app using reactjs, one particular challenge I encounter is ensuring its responsiveness. An issue arises when the browser size changes, causing my components to overlap and lose alignment. Is there an easy solution to preven ...

Create an element that spans the entire width of the page

Having trouble adjusting the width of the .navbar? It seems to only grow to one side and setting it to 100% width doesn't expand it to fill the whole page. Can anyone provide some guidance or assistance? Here's the code: return ( <div cla ...

What is the best way to add a custom class alongside cdk-overlay-pane for a material menu in Angular 7?

I have a specific requirement to create a mega menu using Angular Material Menu. I attempted to apply some custom styling to the cdk-overlay-pane using my own class, but it did not work as expected. I tried to add a custom class to the mat-menu element us ...

How can I create additional white space at the end of my webpage with CSS grid?

Looking for some help with CSS as a beginner here. I'm facing an issue where my CSS is creating excessive blank space at the bottom of my document, almost 60% of it. Could this be due to incorrect parent parameters or the children elements? This is m ...

Moving icon that appears when hovering over a menu button

Before diving into this, please take a moment to visit the following website to understand my goal: You'll notice there is a noticeable RED arrow positioned below the menu. What I aim to accomplish is... when I hover over a menu button, the arrow smo ...

Incorporating images with text in the navigation bar

Just dipping my toes into the world of HTML and CSS, but I need some guidance. I'm trying to incorporate images and text (for the title) in my header using a navbar. However, when I resize the window, the text doesn't move along with the image. ...

What is the reason behind a stationary lightbox sticking to the top of the webpage rather than the top of the viewport?

When you visit this page and scroll down a little before clicking on one of the art pieces, have you noticed that the "fixed" lightbox seems to be attaching itself to the top of the page instead of the viewport? I'm looking for ways to make it attach ...

What is the best way to vertically align the dropdown button with the other text boxes?

I'm currently utilizing a basic bootstrap template from getbootstrap.com. I am having trouble properly aligning the account type dropdown in this section. Additionally, the dropdown list items are not correctly aligned with the dropdown button. Any as ...

Utilize Bootstrap v4 in styling and aligning buttons for a polished

With Bootstrap v4 dropping the .btn-group-justified class, a solution can be found at https://github.com/twbs/bootstrap/issues/17631 Here's how to justify the buttons: <div class="btn-group btn-group-justified" role="group" aria-label="Justified ...

Converting Selenium Webdriver Xpath value to CSS: A Step-by-Step

We are looking to transform the lengthy HTML Xpath values in the existing code into a shorter CSS value: driver.findElement(By.cssSelector(".form button")).click(); ...

The combination of using p:inputText within p:layoutUnit does not function properly when placed inside p

Recently, I encountered a problem with a modal dialog that contains some input components. The issue arose when I implemented a p:layout within the dialog. Initially, the p:inputText component within a p:layoutUnit functioned properly and gained focus. Ho ...

CSS Testimonial Slider - Customer Feedback Display

I'm having some issues with the code below: <div id="box"> <div class="wrapper"> <div class="testimonial-container" id="testimonial-container"> <div id="testimon ...

Is there a way to adjust the width of my web layout without sacrificing its responsiveness?

Struggling with my website layout design as I encountered an issue. The overall width of the layout is too excessive, and I want to introduce some margins on the sides for a better visual appeal. Although the responsive design works well originally, adding ...

Prevent background image animation in CSS

I've encountered an issue with a simple button I created that uses two background images for normal and hover states. Upon testing in various browsers, I noticed that the images animate on hover, causing them to slide up and down. I tried eliminating ...

What is the code to create a forward slash on a webpage using HTML/CSS?

I want to create a unique parallelogram/slash design on my website. While it's simple to place two rectangles side by side, achieving the slash effect is proving to be quite challenging. Can this be done using only CSS or HTML, or does it require SVGs ...

Is there a way in CSS to enable caps lock for specific characters only?

After downloading a new font and setting font-variant: small-caps;, I noticed that my numbers appear much larger than the letters. Is there a way to apply small caps only to the letters, not the numbers? While traditionally numbers do not have a capital ...

Watch the video and follow along with your mouse using jQuery

Wouldn't it be cool to have a video play and follow your mouse pointer when you hover over the red box? And then once you move away, the video stops and disappears. Check out my progress so far: jsfiddle Here's the jQuery code I've used: $ ...

Instructions for utilizing the nav-pill with nav-justified components in Bootstrap3x without incorporating any responsive capabilities

I'm eager to incorporate this into my project : <div class="container"> <ul class="nav nav-pills nav-justified"> <li class="active"><a href="#">Home</a></li> <li><a href="#"> ...

The intersection observer fails to detect any new elements or entries that are appended to the page after it has

When I press the "add section" button to create a new section, the intersection observer does not seem to observe it. Even when I try to run the observer again after pressing the button, it still doesn't work. I suspect that I need to reassign the `se ...

Angular 8 is facing an issue where classes defined dynamically in the 'host' property of a directive are not being properly applied to the parent template

In my Angular 8 application, I am working on implementing sorting using the ng-bootstrap table. I referred to the example available at . In the sample, when I hover over the table header, it changes to a hand pointer with a highlighted class applied as sho ...