Analysis and solution of the reasons for left and right jumps when loading web pages

Analysis and solution of the reasons for left and right jumps when loading web pages
I have been having this problem recently when designing websites. After designing the member center, with the content centered with margin:0 auto;, the webpage will swing to the left the moment it is opened, and then to the right when entering another page, and then swing back to the left. If you jump between pages frequently, you will feel dizzy. The reason is that when the height of the webpage is not enough, the scroll bar on the right will not appear. Here, the width of the webpage must be added to the width of the scroll bar. When margin:0 auto; is used, the webpage is centered, but when the height of the webpage allows the browser to have a scroll bar, the width of the webpage must of course be subtracted from the width of the scroll bar, and then the webpage will swing a little to the left.

Otherwise, do you understand what I said above? Many people should have experienced this situation. The solution is very simple, just make the right scroll bar appear all the time in the style sheet (CSS). When the webpage is not high enough, the browser will also make it appear when the right scroll bar appears. The code is:

Copy code
The code is as follows:

html{overflow-y:scroll;}

<<:  This article will show you the basics of JavaScript: deep copy and shallow copy

>>:  Detailed tutorial on using Docker to build Gitlab based on CentOS8 system

Recommend

How to install nginx in centos7

Install the required environment 1. gcc installat...

Win10 + Ubuntu 16.04 dual system perfect installation tutorial [detailed]

Be sure to remember to back up your data, it is p...

JS realizes the card dealing animation

This article example shares the specific code of ...

Vue-pdf implements online preview of PDF files

Preface In most projects, you will encounter onli...

Example of using docker compose to build a consul cluster environment

Basic concepts of consul Server mode and client m...

How to prompt and open hyperlink a

<br />The countless information on the Inter...

Detailed analysis of binlog_format mode and configuration in MySQL

There are three main ways of MySQL replication: S...

Interpretation of Vue component registration method

Table of contents Overview 1. Global Registration...

JS implements a simple brick-breaking pinball game

This article shares the specific code of JS to im...

js dynamically generates tables (node ​​operations)

This article example shares the specific code of ...

Apache Spark 2.0 jobs take a long time to finish when they are finished

Phenomenon When using Apache Spark 2.x, you may e...

Implementation of one-click TLS encryption for docker remote api

Table of contents 1. Change the 2375 port of Dock...

Nginx Linux installation and deployment detailed tutorial

1. Introduction to Nginx Nginx is a web server th...

Briefly describe the difference between MySQL and Oracle

1. Oracle is a large database while MySQL is a sm...