What could be the reason for my CSS transform animation not functioning properly on Next.js?

In previous projects, I have successfully implemented similar code multiple times without any issues. However, now that I am working on NextJS, I suspect there might be something in the configuration or my approach that is causing a problem. The simple bounce-up effect when hovering or clicking doesn't seem to work at all. Even though Next JS primarily focuses on static site generation, it shouldn't impact how the compiled CSS (using Sass) functions on the client side.

<li className={styles.navbar__link}>
              <a href="#" className={styles.buttonsecondary}>Get Started</a>
            </li>
          </ul>
// css

@keyframes bounceup {
    0% {
        transform: translate(0);
    }

    100% {
        transform: translateY(-.3rem);
    }
}

.buttonsecondary:link, .buttonsecondary:visited {
    background-color: var(--main-color-lightother);
    padding: .8rem 1.6rem;
    border-radius: 1.1rem;
    color: var(--main-color-darker) !important;
    transition: all 0.3s;
}

.buttonsecondary:hover, .buttonsecondary:active {
    transform: translateY(-.3rem);
}

I also attempted using a keyframe animation and incorporating that instead, but neither method yielded successful results.

Due to a peculiar situation, I had to include !important as the only way to select the buttonsecondary class. While I only have a few navigation links on my page currently, this particular one is proving to be troublesome in terms of simple styling.

Answer №1

// CSS Animation

@keyframes bounceup {
    0% {
        transform: translate(0);
    }

    100% {
        transform: translateY(-.3rem);
    }
}

.buttonsecondary:link, .buttonsecondary:visited {
    background-color: var(--main-color-lightother);
    padding: .8rem 1.6rem;
    border-radius: 1.1rem;
    color: var(--main-color-darker) !important;
    transition: all 0.3s;
}

.buttonsecondary:hover, .buttonsecondary:active {
    animation-name: bounceup;
    animation-duration: 0.3s;
}

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 a grid layout created with CSS, the fourth member in every row appears to be misaligned

I have 16 boxes, and they are divided into 4 groups. There is an alignment issue in my code where the 4th member of each row drops down to the next line. I am looking to keep the 4 groups of boxes in a single row without any of them dropping down to the ...

Switching out an element within a constrained array causes a momentary disappearance of the item

My playlist features artwork images that can be clicked. Upon clicking an image, the current track is replaced by the new selection in the array. An issue arises when Ember re-renders the items, causing a brief moment where the replaced element disappears ...

For Flexbox front end design, the left side should be contained within a container while the right side should seamlessly stretch across the

https://i.sstatic.net/3RYY6.png I'm facing a challenge in designing a website with a unique layout that has left me puzzled. I've created a codepen example to showcase what I'm trying to achieve. Specifically, I need to implement a Hero Ba ...

Why does the error "property undefined" keep popping up even though I've already declared it?

Currently, I am facing an issue with toggling the theme in my project. I am encountering difficulties with the types involved, and I am unsure whether the problem lies within my TypeScript configuration or my actual code itself. I attempted to replicate t ...

Modifying the MUI TextField assistant message erases the input value

I recently encountered an issue with my MUI dialog prompting users for their information. Essentially, when the "submit" button is clicked twice, it clears the props of the result object. I have provided a full JSfiddle for reference: https://jsfiddle.net/ ...

Tips for adding labels to buttons in mui-datatables

I'm using mui-datatables in a React app and it's working well, but I want to add labels next to the sort and search buttons. Is there a way to do this? Thanks! https://i.stack.imgur.com/Fi1w0.png Here is my current options object: const options ...

Testing axios requests using react testing library and jest: A comprehensive guide

Trying to ensure that the onSubmit function is handled correctly after clicking the search button. My approach involves testing the inner workings of the onSubmit function, specifically focusing on the behavior of the axios request. In my test, I mocked ...

Establish a connection that mirrors the previously clicked hyperlink

I am attempting to create a functionality where a link can return to a specific link that matches the one clicked on a main page. For example: <a href="link.html" onclick="store this link in memory" target=home></a> <a href="the stored lin ...

Adding a dynamic form to each row in a table: A step-by-step guide

https://i.sstatic.net/HctnU.jpg Hey there! I'm facing a challenge with dynamically generated rows in a form. I want to send only the inputs from the selected row when a checkbox is clicked. Can you help me figure this out? I tried using let rowForm ...

Organize information before making a choice in the dropdown menu

Currently, I have a dropdown menu in HTML that allows you to order the data by different options: <select ng-model="sortOrder" ng-options="option.value as option.name for item in options"></select> In addition, I have implemented code using n ...

Place the vertically centered div with a height that exceeds the viewport's height

I have been trying to find a solution to my question, but I can't seem to locate any answers. I have a webpage with a main div that contains all the content. I centered it using the following CSS: .center { position: relative; top: 50%; transfo ...

React-built NPM website fails to compile

After successfully running my website created with ReactJS on my local machine, I encountered an error when trying to build it using npm run build. The error message received was: > react-snap � pageerror at /personal-site/: SyntaxError: Unexpected ...

The button is only partially visible

My HTML code for a small web app has a button that says "ok," but it's too tiny to display the text fully. I wonder if I'm missing something with the span element? How can I enlarge the button so that it's bigger and shows the entire "ok" ...

Display div content depending on the clicked ID in AngularJS

Unique Header Links HTML <ul ng-controller="pageRouteCtrl"> <li ui-sref-active="active"> <a ui-sref="home" class="" ng-click="getPageId('live-view')">LIVE</a> </li> <li> <a ng-clic ...

CSS - Overlapping elements on smaller screens due to being stacked

I am encountering an issue with a column of elements stacked below each other in my code. Here is a simplified version of my implementation: <div style="position: relative; height: 100%;"> <div style="position: absolute;">Really long text h ...

Using React's Ref to handle conditional rendering and handling the case when

I am facing an issue with my React ref animationRef being null when I conditionally render an element. It works perfectly fine outside of the condition, but not within it. Is there a way to ensure that the ref has a value even when conditionally renderin ...

Reacting to each change event, Angular dynamically loads new autocomplete options

I am facing an issue with my form where users need to select a company using mat-select-search. Upon selection, an API call is made with the selected company ID to fetch users from that company for the autocomplete feature in recipient fields. The process ...

Issue with component not updating when utilizing the 'content' attribute in react-insta-stories

As I experiment with creating stories using react-insta-stories, I am utilizing the content property to showcase the story content. One challenge I encountered is modifying a variable within the handleclick() function. Interested individuals can explore mo ...

how to dynamically add classes in jsx with a combination of tailwind and regular classes

Why is it that in Nextjs 14 (ReactJS 18), when I conditionally assign css classes within a jsx code like this: <Swiper className={lightbox ? "swiperLightbox h-[80%] md:h-[70vh] z-50" : "swiperMain h-[21vmax] rounded-xl"} > ...

Executing multiple mutations using React Apollo client

I have a table in datasheet format containing a list of records that require updating their values. My goal is to initiate a single Submit action and send an array of records as a single argument to the set query in GraphQL. These records are actually Mong ...