Detailed explanation of overflow-scrolling to solve scrolling lag problem

Detailed explanation of overflow-scrolling to solve scrolling lag problem

Preface

If you use the overflow: scroll attribute for a div or module, there will be obvious lag when browsing on an iOS phone. However, this problem does not occur on Android phones.

Workaround

The following code can solve this lag problem: -webkit-overflow-scrolling: touch;, because this line of code enables the hardware acceleration feature, so the sliding is very smooth. This method can indeed solve the sliding lag problem of iOS5.0 and Android4.0 and later systems.

-webkit-overflow-scrolling: auto | touch;

auto: Normal scrolling. When the finger is removed from the touch screen, the scrolling stops immediately.

Touch: Scroll rebound effect. When the finger is removed from the touch screen, the content will keep scrolling for a while. The speed and duration of continued scrolling are proportional to the intensity of the scrolling gesture. A new stacking context is also created.

Compatible writing

over-flow: auto; /* winphone8 and android4+ */
-webkit-overflow-scrolling: touch; /* ios5+ */

ps:

1. If adding this property does not work, add overflow-y: scroll and it will work.

2. When an element is set with position: absolute|relative and then the -webkit-overflow-scrolling: touch; attribute is added, you will find that the scrolling area will get stuck after sliding a few times and cannot slide anymore. In this case, just increase the z-index value of the element.

References: https://www.jianshu.com/p/1f4693d0ad2d

https://www.cnblogs.com/wuyinghong/p/7450041.html

This is the end of this article on how to solve the scrolling jam problem with overflow-scrolling. For more information about overflow-scrolling jam, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. We hope that everyone will support 123WORDPRESS.COM in the future!

<<:  HTML Nine-grid Layout Implementation Method

>>:  Creating private members in JavaScript

Recommend

Three common ways to embed CSS in HTML documents

The following three methods are commonly used to d...

5 ways to achieve the diagonal header effect in the table

Everyone must be familiar with table. We often en...

How to pass the value of the select drop-down box to the id to implement the code

The complete code is as follows : HTML code: Copy ...

JavaScript imitates Xiaomi carousel effect

This article is a self-written imitation of the X...

How to install Apache service in Linux operating system

Download link: Operating Environment CentOS 7.6 i...

Web page HTML code: production of scrolling text

In this section, the author describes the special...

How to write beautiful HTML code

What Beautiful HTML Code Looks Like How to write ...

How to prevent Vue from flashing in small projects

Summary HTML: element plus v-cloak CSS: [v-cloak]...

Basic notes on html and css (must read for front-end)

When I first came into contact with HTML, I alway...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

The correct way to migrate MySQL data to Oracle

There is a table student in the mysql database, i...

Docker - Summary of 3 ways to modify container mount directories

Method 1: Modify the configuration file (need to ...

Introduction to Nginx regular expression related parameters and rules

Preface Recently, I have been helping clients con...