js function code to get the size of the scroll bar_javascript skills
This is relatively simple, just a record.
Create a nested node, let the outer node generate a scroll bar, and then use offsetWidth - clientWidth to get the scroll bar width. It should be noted that in order to avoid page shaking, you can set the outer element position:absolute and visibility:hidden
Reference:
function getScrollWith(){
var wrap = setAttributes(document.createElement('div'),{
style : {
width : '200px',
height: '200px',
overflow: 'auto',
position:'absolute',
visibility:'hidden'
}
})
var inner = setAttributes(document.createElement('div'),{
style : {
width : '100px',
height: '2000px'
}
})
document.body.appendChild(wrap);
wrap.appendChild(inner);
var w = wrap.offsetWidth - wrap.clientWidth;
document.body.removeChild(wrap);
wrap = null;
inner = null;
return w;
}
function setAttributes(elem,opts){
for(var key in opts){
if(typeof opts [key] == 'string'){
elem[key] = opts[key];
}else{
if(!elem[key]){
elem[key] = { };
}
setAttributes(elem[key],opts[key]);
}
}
return elem;
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Unlike Windows 10, Windows 11 features new modern “fluid scrollbars” that change shape when users interact with them. Fluent scrollbars are dynamic in nature, they automatically scale in different form factors or when you change the window size, and it is currently used in apps like Settings, Media Players, and more. Google Chrome may soon have smooth scrollbar functionality, according to a new proposal from Microsoft. Microsoft says in a proposal that they want to modernize old scroll bars in Chrome

A4 paper is now used in many places, such as office, study, etc. The paper used for copying is basically A4 paper. Many friends don’t know how many centimeters the size of A4 paper is. Let’s take a look. Bar. 1. Size A4 paper is 21cm × 29.7cm (210mm × 297mm). The paper size used in most countries in the world adopts this international standard. 2. Origin A4 paper is 210mm×297mm. Reason 1: A rectangle with a length of 2 and a width of The resulting ratio is . However, 297 divided by 210, the result is 1.414, which is close to, and this ratio is exactly a piece of paper

How to hide scroll bar scrolling in react: 1. Open the corresponding "react-native" file; 2. Set horizontal scrolling through horizontal; 3. Hide the horizontal scroll bar by setting the value of "showsHorizontalScrollIndicator" to "false".

How to calculate computer size: 1. Find a flat and stable table, place the monitor on the table, and keep the monitor stable; 2. Use a ruler to measure the diagonal length; 3. Convert the units between centimeters and feet. , just calculate the monitor size.

1. The aspect ratio of A4 paper is different from the common 2:3 or 3:4. Its unique ratio of √2:1 makes it stand out among many paper sizes. 2. This special ratio provides ideal visual effects and practicality for A4 paper.

Recently, some friends have consulted the editor about how to set the scroll bar of the Mac system to always display. The following will bring you the method of setting the scroll bar of the Mac system to always display. Friends who need it can learn more. Step 1: In the system start menu, select the [System Preferences] option. Step 3: On the System Preferences page, select the [General] option. Step 3: On the general page, select [Always] to display scroll bars.

Many friends use cameras to record their living habits. Some professional photography friends may also use SLR cameras to take clearer photos. However, although the photos taken by SLR cameras are clear, for a photo of tens of megabytes, it will undoubtedly increase the pressure on the storage device. So, is there any way to reduce the size of the photo while retaining the details of the picture as much as possible? In fact, just compress the image. So how to compress the image size? Here are two good methods to share. Method 1: We can import the image in the beauty tool without any other processing and editing. When saving a picture, the system will provide image quality adjustment options, and we can drag the slider to adjust the retained sharpness. When the estimated size meets your needs, click Save. Method 2: ①. First open this "

1. A5 paper is an international standard paper size, its size is 148 mm x 210 mm (5.83 inches x 8.27 inches). 2. It is often used in various applications such as letterheads, notebooks, leaflets, and books. 3. The size of A5 paper is slightly larger than half of A4 paper, and it is the fifth size in the A series of paper sizes. 4. This series of sizes was developed by German engineer Walter Portmann in the early 20th century to create a series of standard paper sizes based on the golden ratio.
