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

In what ways can I incorporate Django template tags into my JavaScript code?

I've encountered an issue with implementing my model data into a FullCalendar library template in JavaScript. Despite seeing others do the same successfully, I keep getting errors as the template tags fail to register properly. <script> documen ...

Issue with JavaScript ScrollTop

Simply put, I am trying to determine the total scroll size for a text area in a unit that scrollTop can align with. However, I am at a loss on how to do so. I've tried scrollHeight and various other methods without success. Any advice or suggestions ...

Unexpected CSS counter reset issue encountered within nested elements

Utilizing css counters for the formatting of certain wiki pages is a common practice that I implement by adding CSS directly to the wiki page. One particular use case involves numbering headers using counters. Below is a snippet of the code that demonstra ...

Troubleshooting: Difficulty with svg mask function when implementing an svg image in a react.js environment

I'm attempting to achieve an effect where an image appears above a background image when hovering over it, similar to this example... https://jsfiddle.net/12zqhqod/7/ <img id="heretic" height="300px" width="300px" src="http://i.imgur.com/0bKGVYB ...

Creating an app using Ionic 1 that features scrollable tabs with the ability to handle overflow

My current code snippet is displayed below. On smaller mobile screens, all 7 tabs are not visible at once and instead appear in two rows which looks messy. I want to modify the display so that only 3 tabs are visible at a time and can be scrolled through. ...

Creating an animated CSS growth effect using inline SVG

I'm trying to make these circuits look like they are running downwards. I have the right movement, but I can't seem to start them at their actual size, causing them to appear skewed at the beginning of the animation and then scaling to full size ...

Increase the dropdown size without altering the dimensions of the container

I have a dropdown menu enclosed in a div with a vibrant yellow background. Take a look at the code on Plunker here. Upon clicking the dropdown button, the list expands and the container's height increases as well. The background color of the dropdown ...

Live server feature in Visual Studio Code is not able to update CSS styles

Here's the problem: I'm encountering a CSS styling issue with the Live Server extension in Visual Studio Code (by ritwickdey). When I launch the live preview, none of my CSS styles are being applied. Although the HTML displays correctly, the CSS ...

What is the best way to combine two rows in a data table?

As I progress with my endeavor to construct a user-friendly transition matrix in R, following up on the previous post regarding adding a vertical line to the first column header in a data table, I am faced with a new challenge. Upon executing the provided ...

When using JQuery's .each method, only the first two elements from an array of automatically generated elements are retrieved

I have a loop that creates multiple divs with the class panel. @for(comment <- event.getCommentsSorted()) { However, when I try to manipulate each of these divs using jQuery's .each, only the first two divs are selected. $(window).on('load& ...

Elements are not detected after applying display:none

Within the onLoad event, I implemented a function to hide multiple div elements by setting their CSS property display to "none" and assigning them the class name "invisible": function hideContent() { laElements = document.getElementById("content").chil ...

What is the process for implementing hover transitions on link elements?

I am trying to incorporate a transition effect for my links. Essentially, I want the text-decoration (which is currently set to underlink) to gradually appear. Unfortunately, my previous attempt at achieving this has been unsuccessful: #slink{ transit ...

showing sections that collapse next to each other

I am currently designing a portfolio website using HTML, CSS, and vanilla JavaScript. I have implemented collapsing sections that expand when clicked on. However, the buttons for these sections are stacked vertically and I want to place them side by side. ...

Customized Quick Access MUI

Hey there! I'm currently working with the Speed ​​dial component for MUI and I'm having trouble figuring out how to style the tooltipTytle. I can only seem to style them when they are all displayed at once, but that's not what I want. I ...

CSS mismatch detected between production and development modes

Currently, I am utilizing the Vuetify framework coupled with custom CSS for a project developed using a webpack template. During development mode, my custom CSS modifications are successfully applied to HTML elements; however, in Production mode, these cha ...

Tips for positioning images in the center of a footer

Hello, I am new to coding and would like some help adjusting the code for this website: The footer section at the bottom of each page features a row of logos. My goal is to make sure that these logo images display properly on mobile devices (without dropp ...

Tips for positioning a 404 message at the center of a webpage

Struggling with centering a 404 error message on your Bootstrap 5 page without messing up the footer layout? When the viewport is small, the 404 message may end up getting covered by the footer. Feel free to check out the code snippet in full view to see ...

Is it possible to automatically close navigation dropdowns when the screen size changes?

I am using a bootstrap 4 navbar with dropdowns that open with CSS animation/fade-in on desktop, and a separate toggle button for mobile. Everything works fine, but when I open the dropdowns on mobile and then resize the window screen, they remain open whic ...

The height attribute in HTML tables fails to restrict height in Firefox

Is there a way to restrict the height of a table while still being able to scroll through the hidden elements? I've tried a few methods but none seem to work as intended: http://www.example.com/code/example table.ex1 { table-layout: auto; h ...

Ways to style text using variables in SASS without using quotation marks

When working in SASS, I have created the following mixin: @mixin background_gradient($dir, $from, $to) { background: linear-gradient('to #{$dir}', $from, $to); // for IE10 } However, when viewing it in the browser, the output appears as: b ...