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

Generate code in Yii2 using the active form

This is the code I am using in Yii2: <?= $form->field($model, 'username')->label(false); ?> <?= $form->field($model, 'password')->label(false); ?> It produces the following output: <div class="form-group fi ...

Enhance the HTML content using a JavaScript function

Here is the code that I have: <label>Brand</label></br> <select name="brand" id="brand" onChange="changecat(this.value);"> <option value="" selected>Select Brand</option> <option value="A">AMD</option&g ...

URL to section of website without the navigation bar portion

I am trying to solve a problem with creating a link that will take me to a specific part of the page while taking into account the height of the navbar. The issue is that since the navbar is fixed to the top with a solid color, it ends up covering part of ...

Obtaining the selected value from a material select dropdown in a react application

Struggling to retrieve the value from a select drop-down using onChange event in react, but the function isn't triggering. handleInputChange(event) { alert("testing") event.persist(); this.setState((state) => { state.registerForm[event ...

The backface remains visible despite being designated as "hidden"

I have successfully created a "flip card" in CSS3, where the card flips downward to reveal the other side when a user hovers over it. I have ensured that the back face is not visible by setting backface-visibility to hidden. However, despite my efforts, th ...

How can I achieve a similar layout in my .cshtml file?

https://i.sstatic.net/f1C0G.png Hey there, I'm looking to achieve a layout similar to the one shown in the image. Specifically, I want the left side panel to remain unchanged when expanding the Accordion control on the right side. Can someone guide ...

What are the steps to restrict the scope of a <style> declaration in HTML?

Currently, I am in the process of creating a user interface for a webmail. Whenever I receive an email, I extract its content and place it within a <div> element for display purposes. However, one challenge that I am facing is that each email contain ...

What causes the useEffect to execute prior to the component being re-rendered?

I'm diving into React for the first time and working on a basic counter that increases value by 5. Through my learning process, I discovered that useEffect runs after every component re-render or when there is a change in dependent variables. However, ...

Showcasing an item hidden behind text and a dropdown menu

I have made changes to the background image in my Wordpress theme and now I want to display another image on top of the white content area. To achieve this, I used the following code: img style="position: absolute; top:244px; left: 220px;" src="http://ww ...

In JavaScript, I'm facing an issue where I can't seem to use ' ' for line breaks for some reason. It's not functioning as expected, and I'm

It seems that I have been struggling with writing a new line in my code using "\n". Despite multiple attempts, the desired outcome has not been achieved. Below is my source code along with a screenshot of the result: var ary3 = new Array('seve ...

Update not being displayed on child component's UI

I am having an issue with two parent components, FirstParent and SecondParent, both of which share a common child component called Child. When I click on the Icon within FirstParent, the Redux state updates successfully and the UI displays the Text value ...

I am curious about why the renderValue function is not being triggered. My intention is to add a placeholder to the Select dropdown

The "renderValue" function is not working as expected. I am trying to set a custom placeholder for the Select dropdown but it is not displaying. Here is the code for the Select component: <Select className={classNames({ error: !!error })} ...

Creating elegant text in HTML using only CSSLearn how to design stylish text using CSS without any additional code

Can you generate stylish text using just CSS in HTML? Check out this link for a great demonstration of fancy text. ...

Ensure that PHP form validations are checked when submitting the form using jQuery

I have created a form in HTML with basic verification. Here is the code: <form class="" action="submit/save" method="POST" enctype="multipart/form-data" id="submit_form"> <input class="form- ...

The button effortlessly transforms into a sleek email submission form

I have a button that is already styled with basic CSS properties for active and hover states. I would like to add functionality so that when the "Join the Loop" button is clicked, it transforms into a simple email form similar to the one found at Apologie ...

Is there a way to prevent the Material UI Chip component from appearing when there is no content present?

I have developed an application that pulls content from an API and displays it on the screen. Within this app, I have implemented a Material UI Card component to showcase the retrieved information, along with a MUI Chip component nested within the card. &l ...

Having trouble establishing a default route with React Router v5

I am facing an issue with setting the default route to the home page in react router v5. Despite trying several methods, I cannot get it to work as expected. Index.js import React from "react"; import ReactDOM from "react-dom"; import ...

Leveraging ag-grid within a React application

Within my application, there exists a structure with four distinct tabs. Each tab is intended to display a unique dataset, yet at this time, only two datasets have been defined. Upon executing the code provided below, an error is produced indicating an i ...

Integrate, Delay, Experimentalize, and Attach components

This inquiry might lean more towards a general browser/javascript discussion rather than a focused prototype question, but I believe this community possesses a deep understanding of javascript and browsers. With that said, here is my query: If the followi ...

Make TextField with type number forcibly show dot as decimal separator

I am currently utilizing the material-ui library to display a TextField component in my react application. Strangely, all instances of <TextField type="number /> are displaying decimal separators as commas (,) instead of dots (.), causing confusion f ...