a small bug about fixed jitter

Foreword

Everyone knows that position: fixed is used to generate absolutely positioned elements, positioned relative to the browser window. The location of the element is specified by the "left", "top", "right" and "bottom" attributes.

Suddenly I found that there was a small bug in the webpage I wrote before: In the settlement button part of the purchase page, there is an interaction that is normal based on the standard document static flow layout under the shopping cart. When the webpage monitor wheel is in the upper part, it will be fixedly fixed. Appears below the user's browser; because the button has a hover effect, there will be probabilistic jitter, as shown below:

Detailed description

After many tests, I found that jitter is probabilistic; the first intuition was that it was a Chrome browser problem, then tested different versions, and changed to other browsers, and found that there were problems; then I set the background color of all the boxes. Found a problem: the actual box model in the eye will be a little higher than the box model area pointed to by the mouse:

Jitter

Normal box model

This knows the specific problem, that is, the more than 1px pixels that are topped out, it seems that there is no problem in static view, but once some effects are added, there will be jitter and the experience is very poor. But because it is a probabilistic problem, suddenly I don’t know how to solve it?

problem solved

I tried it maybe a code conflict, so I deleted the relevant code, and it didn't work! Suddenly remembered that I had read an article about how to optimize the performance of animation. I said a solution to the jitter, so I tried to add:

-webkit-transform: translateZ(0);
transform: translateZ(0);
Copy code

Repeated testing, the bug is really solved.

to sum up

There are two general optimizations about css3 animation performance:

  • Try to use transform as an animation, avoid using height, width, margin, padding, etc. directly;
  • It is recommended to enable browser GPU hardware acceleration

Therefore, we use tanslateZ (0) to become a 3d effect, open the browser GPU hardware acceleration, improve the performance of the browser rendering; above the fixed positioning page element rearrangement redrawing the box model bug may be caused by web page rendering, So similar bugs or jitters can be tried with tanslateZ(0), but there are also disadvantages such as power consumption and heat.

Reprinted at: https://juejin.im/post/5afac17151882542714fea44

Intelligent Recommendation

Network small fish Java's bug small collection 0016-SQL statement fixed syntax

This bug is an incorrect example, and the screenshot of the "Case Field" evidence is entered when learning the SQL statement execution. If the connection between multiple conditions in the S...

Moving end fixed element jitter problem

We found in the work, to add an element of fixed property, leave it attached to a window position, directly add fposition: fixed property will be able to achieve this effect; Effect on Android phones ...

[Solved] Position: fixed jitter problem in IOS devices

Recently, I am developing a mobile page. The page has a small icon similar to a smart assistant, which needs to be always suspended in the lower right corner. Then I am very happy to add the following...

Perfectly solved the method of fixed jitter problem in IE6

2019 Unicorn Enterprise Heavy Glour Recruitment Python Engineer Standard >>> We can achieve the fixed effect of elements, such as "Back to Top Menu" at the bottom of the web page, t...

Ios mobile side sliding jitter bug

Ios side sliding jitter bug There will be no problems on Android, and there will be jitter on the ios. First Similar to this kind of sliding, there are currently several possible effects: 1. The mask ...

More Recommendation

css small animation jitter breathing

Button breathing light effect Jitter effect @keyframes dou1 { 0% { -webkit-transform: translate(0, 0px); } 50% { -webkit-transform: translate(-0.1rem, 0.1rem); } 100% { -webkit-transform: translate(0,...

I fixed a bug in the modalbox

Http://code.google.com/p/modalbox/issues/detail?id=360 writes   http://code.google.com/p/modalbox/    ...

Fixed a bug of magical thinking

Magical solution to this bug is a step by step ideas 1. Open the second interface alone with no errors, but only time will change the name of an error, something about the name or with modifications, ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top