What could possibly be causing this element to shift side to side (in IE only) during the CSS animation?

UPDATE: Issue occurring on Internet Explorer 10, Windows 7

When using the transform property to adjust the horizontal position of an element during animation, the vertical value is updated as well. However, despite setting the horizontal value to the same as before, it unexpectedly moves!

Why does the horizontal position change even though the value remains constant?

Visit this link for an example.

HTML:

<div class="parent">
  <div class="child">
    <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Circle-yellow.svg/1024px-Circle-yellow.svg.png" />
  </div>
</div>

JavaScript:

document.querySelector( "img" ).onclick = function(event) {
  event.target.className = "test";
}

CSS:

html, body
{
  height: 100%;
}

.parent
{
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: block;
  z-index: 2;
}

.child
{
  position: absolute;
  left: 0;
  top: 0%;
  height: 20%;
  width: 50%;
  text-align: center;
  display: block;
}

.child img
{
  position: absolute;
  top: 35%;
  left: 50%;
  -webkit-transform: translate(-50%,0em) perspective(1px);
  -ms-transform: translate(-50%,0em) perspective(1px);
  transform: translate(-50%,0em) perspective(1px);
  height: 40%;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

@keyframes test
{
  0%, 50%, 100%
  {
    transform: translate(-50%,0em);
    -webkit-transform: translate(-50%,0em);
    -moz-transform: translate(-50%,0em);
  }

  25%
  {
    transform: translate(-50%,-.5em);
    -webkit-transform: translate(-50%,-.5em);
    -moz-transform: translate(-50%,-.5em);
  }

  75%
  {
    transform: translate(-50%,.5em);
    -webkit-transform: translate(-50%,.5em);
    -moz-transform: translate(-50%,.5em);
  }
}

.child img.test
{
  -webkit-animation-name: test;
  -moz-animation-name: test;
  animation-name: test;
  -webkit-animation-duration: 400ms;
  -moz-animation-duration: 400ms;
  animation-duration: 400ms;
  -webkit-animation-iteration-count: 3;
  -moz-animation-iteration-count: 3;
  animation-iteration-count: 3;
  -webkit-animation-timing-function: linear;
  -moz-animation-timing-function: linear;
  animation-timing-function: linear;
  -webkit-animation-fill-mode: none;
  -moz-animation-fill-mode: none;
  animation-fill-mode: none;
}

Answer №1

Update the CSS for .c img by removing the unused perspective transform to resolve the animation issue.

-webkit-transform: translate(-50%,0em);
-ms-transform: translate(-50%,0em);
transform: translate(-50%,0em);

This will fix the problem with the animation.

Answer №2

Noted by @JonUleis, a bug has been detected in IE 10 (on Win 7) where an animation with multiple iterations experiences a brief unset of the element's styles between each iteration. This may result in glitches and strange movements.

The workaround is to limit the animation to 1 iteration and utilize percentages to simulate multiple iterations. However, this means it cannot run infinitely

Check out the demonstration here

@keyframes test
{
  0%, 22%, 44%, 66%, 88%
  {
    transform: translate(-50%,0em);
    -webkit-transform: translate(-50%,0em);
    -moz-transform: translate(-50%,0em);
  }

  11%, 55%
  {
    transform: translate(-50%,-.5em);
    -webkit-transform: translate(-50%,-.5em);
    -moz-transform: translate(-50%,-.5em);
  }

  33%, 77%
  {
    transform: translate(-50%,.5em);
    -webkit-transform: translate(-50%,.5em);
    -moz-transform: translate(-50%,.5em);
  }
}

.c img.test
{
  -webkit-transform: translate(-50%,0em);
  -ms-transform: translate(-50%,0em);
  transform: translate(-50%,0em);
  -webkit-animation-name: test;
  -moz-animation-name: test;
  animation-name: test;
  -webkit-animation-duration: 1000ms;
  -moz-animation-duration: 1000ms;
  animation-duration: 1000ms;
  -webkit-animation-iteration-count: 1;
  -moz-animation-iteration-count: 1;
  animation-iteration-count: 1;
  -webkit-animation-timing-function: linear;
  -moz-animation-timing-function: linear;
  animation-timing-function: linear;
  -webkit-animation-fill-mode: forwards;
  -moz-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

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

How to Generate HTML Reports Using JBoss?

Is there a convenient and efficient way to generate .html reports for JBoss applications that is not time-consuming? I have a database containing entities that I need to display in multiple tables. The report should include links to navigate between secti ...

Alignment of badge-pill and h2 in a horizontal position

I'm currently working on mastering Bootstrap. My goal is to have a prominent heading followed by three small badge-pills that are horizontally centered on the page. However, I've run into a couple of issues: 1- The badge-pills are appearing stac ...

Activate function when list item is clicked

My goal is to execute a function when users click on the li elements in the snippet below without relying solely on onclick. For instance, clicking on the first li element (with a value of 1) should trigger a function where the value "1" is passed as an ar ...

Generating a highchart by retrieving JSON data using AJAX

I'm currently working on generating a basic chart on a webpage using data from a MySQL database that is fetched via a MySQL script. My main challenge lies in understanding how to combine the ajax call with the necessary data for the chart. I'm n ...

JavaScript and HTTP Post parameters: Consider using optional additional parameters

Managing a filtration function, I have an array of checkboxes and dropdowns. Users can select multiple checkboxes and dropdown values before clicking on the "Filter Now" button. Upon clicking the button, a POST request is triggered to my API, passing alon ...

Guide on sorting an array within a specific range and extracting a sample on each side of the outcome

I need a simple solution for the following scenario: let rangeOfInterest = [25 , 44]; let input = [10, 20, 30, 40, 50, 60]; I want to extract values that fall between 25 and 44 (inclusive) from the given input. The range may be within or outside the inpu ...

How to effectively use the LIKE statement in mysql with node.js

app.post('/like/:level/:name', function(req, res){ connection.query("SELECT * from books where " + req.params.level + " like '%" + req.params.name + "'%", function(err, rows, fields) { if (!err){ var row = rows; res.send(row); console.l ...

Conflicts between characters in MySQL, HTML, and PHP

I am encountering an issue while retrieving text from a database. The data is stored as "♦" in the database without any problems. However, when I retrieve the record from the database, it appears on the page as a regular question mark instead of the bla ...

What is the purpose of utilizing "({ })" syntax in jQuery?

What is the purpose of using ({ }) in this context? Does it involve delegation? Can you explain the significance of utilizing this syntax? What elements are being encapsulated within it? For instance: $.ajaxSetup ({ // <-- HERE error: fError, ...

Attempted everything... Clicking away but a div refuses to show up post-click, resulting in an error message

When attempting to click a button, I encountered an error stating that the element is not clickable at point (1333, 75) as another element would receive the click. This issue arose while using Google Chrome version 65. <li class="slds-dropdown-trigge ...

Puppeteer: Easier method for managing new pages opened by clicking a[target="_blank"]; pause for loading and incorporate timeout controls

Overview I'm seeking a more streamlined approach to managing link clicks that open new pages (such as target="_blank" anchor tags). By "handle," I mean: fetch the new page object wait for the new tab to load (with specified timeout) Steps to r ...

I need to access a directory that is outside of my current folder in Express.js

I have two folders within my main folder; one is for front-end and the other is for back-end. project ├── back-end │ ├── public │ └── routes │ ├── Calling.js │ └── index.js └── front-end ├ ...

Creating a Wireframe in Three.js Using a RawShaderMaterial with LineSegments

In the midst of my work on a project, I encountered a dilemma with rendering an intricate wireframe using THREE.LineSegments. My objective is to gradually animate the vertices within this LineSegments material (referred to as warehouse in the project), but ...

``After initialization, the service is unable to retrieve the object as

I have a special service that stores specific objects to be shared among different controllers. Here is an example of the code I am using: $rootScope.$on('controller.event', function(event, arg){ self.backendConnectorService.getBac ...

jQuery receiving improperly formatted HTML from method call

One issue I am facing involves a jQuery Ajax method that anticipates receiving HTML as the return. The JavaScript function's URL leads to a JsonResult method within ASP.NET MVC. To construct the HTML, I am utilizing StringBuilder and checking it in Vi ...

What is the best way to superimpose an image onto a canvas?

I am working on a cool project where I have created a canvas that displays matrix binary code raining down. However, I would like to enhance it by adding an image overlay on top of the canvas. Here is my current setup: <div class="rain"> ...

What is the purpose behind certain developers specifying font size twice using different units?

When creating website themes, I often come across developers defining properties twice with different units. For example: body, button, input, select, textarea { color: #404040; font-family: sans-serif; font-size: 16px; font-size: 1rem; ...

The operation of inserting values into the database encountered an issue due to an invalid cursor state, resulting in a java.sql.SQLException error with the

I am encountering an issue with invalid cursor state error while running this code snippet in my application. The technology stack I am using includes SQL Server 2005 along with JSP and HTML. <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Conn ...

In a React TypeScript application, prevent users from clicking on buttons that represent the same number of answers in a multiple choice question

I'm currently developing a multiple choice component with various properties like the number of options, number of answers, and a callback function to capture user-selected data. Additionally, this component should display a checkmark when a button is ...

AssistanceBubble.js with ASP.NET UpdatePanel

Looking for guidance on implementing HelpBalloon.js () within an ASP.NET UpdatePanel. Experiencing issues with image loss after a postback. ...