What could be causing one Div to animate at a quicker pace than the other?

Why does the div with an id of "Second" animate slightly before the "first" div when using keyframe animation? I expected them to move at the same speed by default. Any help would be greatly appreciated, thank you.

body { background-color: black; color: white;}

#First { width: 200px; 
   height: 50px;  
   position: absolute; 
   top:5px; 
   color: black; 
   text-align: center; 
   background-color: yellow; 
   -webkit-transform-origin: top;
   -webkit-animation: myfirst 1s;
   -webkit-transform:rotateX(90deg);
   -webkit-animation-iteration-count: infinite;
}

@-webkit-keyframes myfirst
{
0%  {-webkit-transform:rotateX(0deg);}
100% {-webkit-transform:rotateX(90deg);}
}

#Second { width: 200px; 
      height: 50px;  
      position: absolute; 
      top:5px;  
      left:200px;
      color: black; 
      text-align: center; 
      background-color: green;
      -webkit-transform-origin: bottom;
      -webkit-animation: mysecond 1s;
      -webkit-transform:rotateX(0deg);
      -webkit-animation-iteration-count: infinite;
}

@-webkit-keyframes mysecond
{
0%  {-webkit-transform:rotateX(90deg);}
100% {-webkit-transform:rotateX(0deg);}
}

Here is the HTML code:

<div id="First">FIRST</div>
<div id="Second">SECOND</div>

You can view the code on jsfiddle here: http://jsfiddle.net/x3p64/

Answer №1

Check out the Demo

When it comes to the @-webkit-keyframes, they were distinct for each scenario

Following the specified requirements

Explore the New Demo

The @-webkit-keyframes myfirst animation:
    0% { -webkit-transform: scaleY(0); }
    20% { -webkit-transform: scaleY(0.2); }
    40% { -webkit-transform: scaleY(0.4); }
    60% { -webkit-transform: scaleY(0.6); }
    80% { -webkit-transform: scaleY(0.8); }
    100% { -webkit-transform: scaleY(1); }

The @-webkit-keyframes mysecond animation:
    0% { -webkit-transform: scaleY(1); }
    20% { -webkit-transform: scaleY(0.8); }
    40% { -webkit-transform: scaleY(0.6); }
    60% { -webkit-transform: scaleY(0.4); }
    80% { -webkit-transform: scaleY(0.2); }
    100% { -webkit-transform: scaleY(0); }

Answer №2

Although it may appear that one animation is starting before the other, it is actually due to the easing properties applied. In reality, both animations are initiated and ceased simultaneously but give off different visual effects. I recommend utilizing a linear easing for consistency in both animations.

-webkit-animation: mysecond 1s linear;

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

JavaScript's setAttribute function is not functioning as expected

I have been using the setAttribue method as shown below. It works perfectly for the first instance, but after that, when I try to change the value, it displays an alert without updating with document.getElementById("to").setAttribute("value", selValue); d ...

How can I adjust or eliminate the offset in Bootstrap 3 for smaller devices like tablets and smartphones?

Within the structure of my web app view (created in Rails 5), this is the main div: <nav class="navbar navbar-inverse navbar-fixed-top" > my navigation bar </nav> <div class="col-md-6 col-md-offset-3"> the central content of my web ...

Receive information from a form and store it in an array

Struggling to figure out how to convert this into an array. I'm having trouble grasping the concept of taking input from a form and storing it in an array. In my project instructions, it clearly states: Do NOT save the input in variables and then tra ...

Extracting information from the 'View all responses' feature

I've been attempting to extract reviews from the following website: . Each review contains 5 ratings such as value for money and customer service. However, most of the information is initially hidden behind a 'See all Answers' button, restri ...

Troubleshooting a Vue.js formatting problem in Visual Studio 2019

Encountering an issue with VS2019 while attempting to format this code section. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="milestone.ascx.cs" Inherits="uc.dms.milestone" %> <section class="content-header"> <h1> ...

What is the best way to use regex to target only the content within a particular set of tags?

While there have been numerous similar inquiries posed before, mine pertains to a specific selection within the tags. I am not interested in extracting the entire content between <a href and </a>, but rather just targeting the "> within th ...

Avoiding double tapping to zoom on Chrome Android while using the desktop version of a website

Is there a way to disable zooming when double clicking in Google Chrome with the desktop site enabled? I attempted to use <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> without success. I al ...

What is the best way to align checkboxes perfectly alongside the rest of the text within the text box?

I need the checkbox to be positioned under the text boxes in a aligned manner. Even though I used the CSS code below to align the text boxes, the checkboxes are not properly aligned: label { width:135px; clear:left; text-align:right; p ...

"I'm experiencing a problem with display:inline in IIS 7 - can anyone

Unfortunately, our development web server cannot be accessed externally, so sharing a link is not possible. However, I can explain the issue we are experiencing. While creating markup for a new website on my local machine, everything appears as intended. ...

Expanding the width of a bootstrap dropdown menu

Looking for advice on how to expand the dropdown width? I have a row with two columns and some JavaScript that handles the dropdown functionality. The issue I'm facing is that I can't figure out how to adjust the dropdown width when it's se ...

What is the best way to position the logo on the left side and the navigation on the right

How can I position my logo to the left of the navigation bar? This is my current HTML code: <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <link rel="icon" type="image/png" href="SENCOR_Logo.ico"> & ...

exploring various dynamic elements using jquery

If you need some help figuring this out, take a look at the JSFiddle here. I've set it up for users to input any data they want in the text box, choose a table from set one, and then click the "submit" button to send it. <div> <Div> < ...

When using PHP, JavaScript, and HTML, you can trigger an image upload immediately after choosing a file using the

I currently have a small form with two buttons - one for browsing and another for uploading an image. I feel that having two separate buttons for this purpose is unnecessary. Is there a way to combine the browse and upload functions into just one button? ...

Performing an AJAX request inside of another AJAX request

I have integrated buttons into my website that are activated by JS AJAX loads. By clicking on these buttons, a JavaScript function is executed to load the contents of a PHP file into a specific div element. This setup is crucial as I want to avoid the enti ...

What is the proper method to define a background image path for both development and production environments?

I am trying to apply a CSS background image to my HTML. Initially, I set it to: html {background-image: url('/assets/background.jpg')} It worked in development, but after the assets were compiled into the Public folder, the path was no longer ...

Transform preexisting Vue UI library measurements into pixels

I was curious about converting all existing units (em / rem) to pixels. How can I easily convert the entire output units to px? Are there any tricks or methods available? Currently, I am utilizing Vuesax UI to create a plugin for various websites and temp ...

Adding a scroll bar: A simple guide

My project includes hidden menus and submenus, but I'm having trouble accessing the last menu because there is no scroll bar. How can I add a scrollbar to my project? If you'd like to check out my project, click here. ...

Video from Brightcove continues to play even after closing the modal dialog

My concept for opening a Brightcove video in a modal dialog when a button is clicked has been successfully implemented. Below is the code snippet I used for this implementation: Html code: <a class="videoTutorialB" href="#">Watc ...

Tips on saving a form submit button data to localStorage

As a newcomer, I am on a quest to make this function properly. My goal is to create a form where the submit button saves data to the localStorage. Here's what I have tried thus far. <script> function storeRecipe() { localStorage.setItem($(" ...

Tips for embedding HTML/CSS snippets in backticks when using TypeScript with AngularJS

Does anyone else experience the issue of their Angular 2 templates showing up as gray text in Visual Studio Code? I'm unable to use autocomplete or see my CSS properly. Is this a settings problem or is there a plugin that can solve this? BTW, I am us ...