What is the reason behind using '-webkit-backface-visibility: hidden;' to resolve problems with negative margin transitions on iOS/iPad 5.1?

During the process of resolving my issue, I accidentally discovered a solution - but I always prefer to understand the fixes I apply.

<ul>
  <li><img src="something.jpg" /></li>
  <li><img src="somethingElse.jpg" /></li>
  [+12 more <li>'s]
</ul>

Here are the CSS styles that I believe are relevant:

ul {
  position: absolute;
  list-style-type: none;
  top: 0;
  left: 0;
}
li {
  position: relative;
  height: 900px;
  width: 500px;
  float: left;
}
img {
  display: block;
  margin: 0 auto;
}

The issue arises when applying a transition that shifts all images to the left, like so:

ul {
  left: -3000px;
}

This transition functions correctly in most cases, except for ios 5.1, where it sometimes works and other times reverts back to displaying the last image set (e.g. first image or an intermediate image).

Surprisingly, adding this line of CSS resolves the problem:

ul {
  -webkit-backface-visibility: hidden;
}

Although this solution does not seem intuitive to me, it effectively eliminates flickering during transitions.

Answer №1

It appears that I have identified the root cause of this issue.

There was a bug in the transition library being utilized, which resulted in translate() being used instead of translate3d(), even though the latter was available.

After rectifying this, the additional CSS rule:

-webkit-backface-visibility: hidden;

no longer made an impact - the transitions smoothly moved the DOM element to its correct position without it.

My deduction from this is that the mentioned CSS rule somehow enforced the use of the translate3d() method on the object.

However, in order to eliminate the slightly choppy movement between frames, I still had to include:

ul {
  -webkit-transform: translate3d(0,0,0);
}

I stumbled upon this solution through trial and error: testing various CSS 'fixes' like:

-webkit-perspective: 0;
-webkit-backface-visibility: hidden;
-webkit-transform: translate3d(0,0,0);
visibility: visible;

and ensuring the use of 'translate3d', gradually removing unnecessary CSS adjustments until only '-webkit-transform: translate3d(0,0,0);' remained critical in one spot.

Therefore, by employing the correct animation call and implementing a specific CSS style in a single location, the overall transition significantly improved :)

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

Issue with IE6: Div inside Anchor element causing inline images to not be clickable links

I am currently facing an issue where I need everything within the anchor tag to be a clickable link, but in IE6 (the only browser I am concerned about at the moment), the inline images are not clickable. I understand that it is not valid HTML to place a di ...

When a child SPAN surpasses the height of the parent TD/TABLE, trim it down

I am attempting to make my outer table/td clip the inner SPAN when the content of the span exceeds the height of the outer table, all while maintaining vertical and center alignment. Instead of the current layout: https://i.sstatic.net/s33q7.png I want ...

Using CSS to create a triangular background within a <div> element

I am looking to create a CSS triangle shape for a background, but I am unsure of how to achieve this or if it is even possible. Ultimately, I want the menu to resemble the image linked below: While I have come across methods to create the desired shape, ...

Elements appear with varying widths in Firefox compared to Webkit-based browsers

I believe it would be simpler for you to inspect the elements rather than me writing the code, so I have provided a link: music band site. Now onto the issue: When the window width is reduced in Firefox, you will notice that the social icons in the yellow ...

How can I display a nested div when the parent div's v-if condition is not met?

In my project, I am utilizing Laravel 6 in combination with Vue.js 2. To iterate through users and showcase their information within div elements, I am using a for loop outlined below. The Category names are stored in user.pivot.demo2, and the users are ...

Navigate to the specified text in the dropdown menu based on the ul li selection

Is it possible to achieve a functionality similar to that of a select box, where typing a keyword that matches an option in the select box will automatically move the pointer to that option? I am looking to implement a similar feature in my HTML code: < ...

Why does the lazy loading feature keep moving the background image around?

While trying to incorporate lazy loading on my website, I encountered an issue where the image position would change after it was fully loaded and made visible. I experimented with rearranging the order in which my JavaScript and CSS files were called, bu ...

Transfer or duplicate an SVG image from the bottom div to the top div

Is there a way to move a div from the chart_div to the movehere div? I've tried duplicating it below the current svg, but I'm having trouble targeting just the header row ('g' element) specifically. Here is the HTML: <script type= ...

Tips for concealing the top button on a mat calendar

I have a calendar for a month and year, but when I click on the top button it also displays the day. How can I hide that button or instruct the calendar not to show the days? Check out this image I was thinking of using a CSS class to hide that element. ...

Using Javascript code to draw particles at the cursor's position and then directing those particles towards the bottom of

I found an interesting JavaScript code snippet that creates a bubble particles effect around the cursor. You can download it from https://github.com/tholman/90s-cursor-effects. However, I encountered a problem when adding certain elements inside a specifi ...

Using jQuery and CSS to Filter and Sort Content

I need help with filtering a list of content based on their class names. The goal is to show specific items when a user clicks on one of two menus. Some items have multiple classes and users should be able to filter by both menus simultaneously. Currently ...

Tips for separating <td> tags within a series of <td>

I am working with the HTML code provided below. <tr> <td class="slds-cell-wrap" data-label="">Category</td> <td class="slds-cell-wrap break" data-label=""><strong> Test </strong></td> <td clas ...

Should we avoid styling HTML tags?

Would it be considered poor practice, for instance, to apply the following CSS rules to all images on my webpage in order to make them responsive: img { display: inline-block; height: auto; max-width: 100%; } Instead of using img-responsive on each ...

Changing the background color to white causes the progress bar line to become indiscernible

Here's how my form appears: https://i.sstatic.net/jXCxm.jpg Once I set the container to be: <div class="container" style="background:white;"> https://i.sstatic.net/DZjAK.png I want to make it white and ensure that the prog ...

Issues with div and hyperlinks/forms

I am currently working on creating a left sidebar in my HTML code, but I am still new to this. In the div for the sidebar, I have three buttons. However, Weebly keeps notifying me of an issue with the <a> tag, and the second button's link appear ...

Arranging elements within the flex container in perfect alignment

I'm stuck trying to figure out how to adjust the layout of a flex container with three child elements. Here is the code I'm working with: html,body,div {margin:0;padding:0;} .cont { display: flex; justify-content: space-between; height: ...

Scroll horizontally within each row

I am attempting to create a table with individual horizontal scrolling for each row, dynamically. Currently, my code only allows the entire table to scroll horizontally, not the individual rows. https://i.sstatic.net/3oaPl.jpg <table class="table-mai ...

What are the best practices for implementing the CSS id selector?

As someone new to web development, I am facing an issue with my code where the CSS id selector is not functioning as expected: li { border: 3px solid red; } h3 { background: green; } #special { color: green; } <h3>Todo List</h3> < ...

Guide for updating the background color, font color, and border color in Material UI's autocomplete textfield

How can I customize the appearance of this material-ui autocomplete textfield (combobox) by changing the background color, font color, and border color using CSS? Here is what I have attempted so far: <Autocomplete disablePortal id=" ...

Customize CSS styling

When it comes to the styling of my first line, I have a specific style in mind: * { text-align:left; } This style works well across most parts of the site as they are predominantly left aligned. However, there are few areas where I need the text alig ...