How to prevent the scroll bar from affecting the page width when the scroll bar appears on the page

How to prevent the scroll bar from affecting the page width when the scroll bar appears on the page
Set the width of the body to the width of the window (controlled by the following script)

$("body").css("width", $(window).width());

At the same time, set the overflow of the body (written in the style)

body{ overflow-x: hidden;}

ps:

Similarly, the table in div is also handled in this way




Set the width of tableContainer (written in the style) and tableMain (controlled by the script) to be equal to the width of tableMainHead


Copy code
The code is as follows:

$(".tableMain").css("width", $(".tableMainHead").css("width"));


Set the overflow of tableContainer to hidden (written in the style)

This has a disadvantage, that is, when the browser window size changes, the content in the body cannot be automatically centered (the div that originally used percentages for width settings could be automatically centered using margin: auto, but now that the extra part is hidden, it cannot be automatically centered)

<<:  Solution to the problem that the div width is set to width:100% and then the padding or margin exceeds the parent element

>>:  Share the pitfalls of MySQL's current_timestamp and their solutions

Recommend

A brief analysis of the configuration items of the Angular CLI release path

Preface Project release always requires packaging...

Example code of javascript select all/unselect all operation in html

Copy code The code is as follows: <html> &l...

A brief discussion of 12 classic problems in Angular

Table of contents 1. Please explain what are the ...

Building .NET Core 2.0 + Nginx + Supervisor environment under Centos7 system

1. Introduction to Linux .NET Core Microsoft has ...

MySql8 WITH RECURSIVE recursive query parent-child collection method

background When developing a feature similar to c...

Example code for implementing the wavy water ball effect using CSS

Today I learned a new CSS special effect, the wav...

Detailed explanation of HTML tables

Function: data display, table application scenari...

WeChat applet implements text scrolling

This article example shares the specific code for...

Analysis of the advantages and disadvantages of MySQL stored procedures

MySQL version 5.0 began to support stored procedu...

javascript countdown prompt box

This article example shares the specific code of ...

Learn MySQL index pushdown in five minutes

Table of contents Preface What is index pushdown?...

CocosCreator Universal Framework Design Network

Table of contents Preface Using websocket Constru...

How to install and deploy gitlab server on centos7

I am using centos 7 64bit system here. I have tri...