CSS animations are not running as expected

Currently, I've been experimenting with a basic CSS animation. The objective is to make the application logo move 200px to the right and then smoothly return to its original position. Below is the code snippet I've used for these animations:


/* LOGO MAIN STYLE */
.App-logo {
  height: 40vmin;
  pointer-events: none;
}

/* ANIMATION FOR THE LOGO */
.App-logo {
  animation-fill-mode: forwards, none;
  animation-name: move-right, move-left;
  animation-delay: 0s, 1s;
  animation-duration: 1s, 1s;
  animation-iteration-count: infinite, infinite;
  animation-timing-function: ease-in-out, ease-in-out;
}

@keyframes move-right {
  from {
    transform: translateX(0%);
  }
  to {
    transform: translateX(200px);
  }
}

@keyframes move-left {
  from {
    transform: translateX(0%);
  }
  to {
    transform: translateX(-200px);
  }
}

The issue I am currently facing is that the initial animation doesn't seem to play as expected; it skips directly to the second animation.

Answer №1

/* STYLING FOR THE MAIN LOGO */
.App-logo {
  height: 40vmin;
  pointer-events: none;
}

/* ANIMATION FOR THE LOGO */
.App-logo {
  animation-name: move-right;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

@keyframes move-right {
  0%{
    transform: translateX(0%);
  }
  50% {
    transform: translateX(200px);
  }
  100% {
    transform: translateX(0px);
  }
}

Answer №2

/* STYLISH LOGO DESIGN */
.Logo-image {
  height: 50vmin;
  pointer-events: none;
}

/* ADDED ANIMATION TO THE LOGO */
.Logo-image {
  animation-name: move-left;
  animation-duration: 0.8s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

@keyframes move-left {
  0%{
    transform: translateX(0%);
  }
  50% {
    transform: translateX(-150px);
  }
  100% {
    transform: translateX(0px);
  }
}

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

React.js Components - Drawer overlays webpage content

I made the decision to include the Drawer component in my React project from the material-ui library. This is how I implemented it: class RightDrawer extends React.Component { state = { open: false, }; handleDrawerOpen = () => { this.set ...

"Can anyone explain why the text color of my font changes during a transition within a

Check it out on jsfiddle as well: https://jsfiddle.net/phmttrsh/ #btn { font-size: 16px; height: 34px; width: 120px; border: 1px solid #20ACB3; text-align: center; line-height: 34px; background-color: #20ACB3; color: #fff ...

Is it possible to alter preact-material-components to switch to mdc-theme--dark mode, thereby changing the CSS style of all descendant components?

I recently created a preact-cli app and added the following code in Header.js: document.body.classList.add('mdc-theme--dark'); However, when a user tries to switch from the light theme to the dark theme, only the background of the app changes. ...

DataGrid Filtering with Material-UI

I recently started working on a React project and I'm trying to incorporate the mui datagrid component. I want to include filters for '>' and '<', but I couldn't find any information in the documentation. Is there a specific p ...

Using the 'as' prop to pass and rendering HTML tags in React

Looking for assistance in passing a component prop named 'as'. The 'as' prop will be connected to HTML tags and the string "link". If the value is "link", I want it to render the Link component from react-router-dom. In all other ins ...

What is the best way to display two radio buttons side by side in HTML?

Looking at my HTML form in this JSFiddle link, you'll see that when the PROCESS button is clicked, a form with two radio buttons appears. Currently, they are displayed vertically, with the female radio button appearing below the male radio button. I& ...

What steps should be taken to proceed with the mounting process once the condition is

I am currently developing a React application and I have an implementation of componentWillMount that is structured as follows: componentWillMount() { axios.get('/user').then(response => { console.log(response.data.user) if (respons ...

Utilizing Material-UI ThemeProvider and createGenerateClassName for Preventing Class Name Overlap

Is there a way to prevent conflicts in a React application using material-ui classNames from makeStyles when including a package that also uses the same naming conventions, resulting in multiple conflicting .jss1, .jss2 styles on the rendered page? Both th ...

Encountered an error during the production build of NEXTJS, where it panicked due to the global thread pool not being initialized

While hosting my app on Heroku and running git push heroku main, I encountered the following error: panicked at 'the global thread pool has not been initialized.: threadpool builderror { kind: ioerror(error { kind: unsupported, message: "operatio ...

How can I resolve the theme.spacing.unit warning in material-ui-dropzone?

When implementing material-ui-dropzone, I encountered the following issue: //App.js <Dropzone/> A warning appeared in the console: index.js:1375 Warning: Material-UI: theme.spacing.unit usage has been deprecated. It will be removed in v5. You can ...

Positioning two distinct Div elements using CSS

In an attempt to align two lists within a div, I have one list containing .jpg files and another with text files. <!DOCTYPE html> <html> <style> .left{height:auto; float:left;} .right{height:auto; float:right;} </style> &l ...

Error: The parent class is not defined as an object

My program is currently attempting to utilize this.state, but I encountered an error. Can anyone provide assistance on resolving this issue? https://i.stack.imgur.com/wgxBf.png ...

Design a dynamic top navigation bar in Angular or any other framework that automatically adjusts to the size of the screen, similar to the responsive bookmarks bar in

Could you offer guidance or suggestions on how to design a navigation bar (using Angular 1, jQuery, CSS, etc) that emulates the functionality of Google Chrome bookmarks bar when resizing the page? Essentially, as the page size decreases, a new button/symbo ...

Cannot render <Image> inside <Section> component

As a beginner in React, I am attempting to create an app following a tutorial. In my component, I utilized the figure tag but it's not showing up when inspecting element in Chrome. Here are the code snippets: The tutorial includes a div tag as a chil ...

Is it necessary to use a specific button to submit on Return (Enter)?

In a wizard-type form, there are two buttons present. The Back button is positioned on the left side, while the Next button is located on the right side. For an example of this setup, visit http://jsfiddle.net/WSwb7/1/. Please note that submitting the form ...

Guide on how to refresh the background image using the identical URL within a directive

I am looking to refresh the background image of a div using the same URL within a directive. Upon loading my view, I utilized this directive to display the image as a background for the div. app.directive('backImg', function () { var dir ...

Syntax highlighting in VSCode does not seem to be functional when the ?? nullish coalescing operator is being utilized

Hello there! I've recently started using react.js with typescript on a new computer, but I've encountered an issue with syntax highlighting in VSCode. It seems that the problem arises when there's a double question mark (??) in the code, spe ...

Trigger a function post-rendering in a React component

Hey everyone, hope you're having a great day! I've been diving into React for a few months now. I'm making an effort to steer clear of using the traditional React Components, opting instead for React Hooks. However, there are instances wher ...

Incorporate HTML and JavaScript to dynamically show a button when a specified condition evaluates as true and hide the button if the

I need help with a scenario where I want to show a button only when a specific variable reaches a certain value. For instance, if the variable equals 5, the button should be displayed; otherwise, it should be hidden. Here are the two buttons included withi ...

What is the best approach to incorporate Column Reordering in react-data-grid?

Within my REACT application, I have incorporated the npm package react-data-grid. They offer a sample showcasing Column Reordering on their website. I wish to replicate this functionality in my own code. Upon reviewing their source code, I am puzzled abou ...