Home > Web Front-end > uni-app > body text

Scroll bar hidden uniapp

WBOY
Release: 2023-05-22 11:21:31
Original
4296 people have browsed it

In UniApp application development, the commonly used scroll bar is a very important interface component. However, in some cases, we want the scroll bar to be invisible on the page, but we cannot directly hide the scroll bar through CSS styles. So, in this case, how to hide the scroll bar? This article will introduce you to several methods to hide scroll bars.

1. Use global css style to hide scroll bars

When applying css style globally on the page, if you want to hide the scroll bar, you can use the following code:

::-webkit-scrollbar {
    display:none !important;
}
Copy after login

This kind The method is achieved through webkit's scroll bar style control. When this style is applied globally, all scroll bars on the page will be hidden.

2. Use inline css style to hide the scroll bar

When embedding the inline CSS style in the page, if you need to hide the scroll bar of a specific scroll container, you can use the following Code:

#scroll-wrapper::-webkit-scrollbar {
    display:none !important;
}
Copy after login

Among them, #scroll-wrapper is the id of the container that needs to hide the scroll bar.

3. Use JavaScript to control the scroll bar hiding

When using JavaScript to control the scroll bar hiding, you can operate it through the following code:

document.documentElement.style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
Copy after login

This JS code will hide the scroll bar The overflow attribute is set to hidden to hide the scroll bar.

Summary

In UniApp application development, the scroll bar is one of the commonly used interface components on the page. However, in some pages, you do not want the scroll bar to be directly visible. After some processing, you can hide the scroll bar through css or js. I hope the above code can help you, everyone is welcome to use it.

The above is the detailed content of Scroll bar hidden uniapp. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template