Home  >  Article  >  Web Front-end  >  Solution to element misalignment when html page scrolls_html/css_WEB-ITnose

Solution to element misalignment when html page scrolls_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:45:541619browse

When a page with a more complex layout is run on a mobile browser, some phones with poor configurations will appear after scrolling the scroll bar. The page will scroll normally, but some elements will appear similar to position: fixed. Generally hover on the page and then scroll. It looks a bit like parallax scrolling, but not pretty at all.

Solution: Add style to the sliding body: transform: translateZ(0); -webkite-transform: translateZ(0).

<div style="height:300px;overflow:auto">    <div style="transform:translateZ(0);-webkite-transform:translateZ(0);">          各种复杂的html      <div></div>

The purpose of adding this is to take advantage of GPU acceleration (GPU cache).

Because of this problem, it was also discovered that if you use overflow:auto to slide the page (html scroll bar form), the browser will frequently scroll, update layer tree, and composite layers every time the page slides. There should be a problem in the last link. The reason for this problem should be the layout method.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn