Home > Web Front-end > CSS Tutorial > How Can I Prevent Scroll Bars from Disappearing on My Mac Trackpad When Using WebKit/Blink Browsers?

How Can I Prevent Scroll Bars from Disappearing on My Mac Trackpad When Using WebKit/Blink Browsers?

Patricia Arquette
Release: 2024-12-08 10:26:11
Original
248 people have browsed it

How Can I Prevent Scroll Bars from Disappearing on My Mac Trackpad When Using WebKit/Blink Browsers?

Preventing Scroll Bars from Vanishing: A Solution for Mac Trackpad Users in WebKit/Blink

Problem:

Users on macOS with Mac OS X Lion (10.7) and later may encounter hidden scroll bars when using a trackpad in WebKit/Blink browsers (like Safari and Chrome). This behavior can lead to confusion, as scroll bars provide an essential visual cue that an element is scrollable.

Solution:

WebKit's -webkit-scrollbar pseudo-elements enable control over scroll bar appearance. By customizing these elements, we can prevent default behavior and force scroll bars to display continuously.

CSS Styling:

Disable the default appearance and behavior:

.frame::-webkit-scrollbar {
    -webkit-appearance: none;
}
Copy after login

Recreate the appearance of visible scroll bars:

.frame::-webkit-scrollbar:vertical {
    width: 11px;
}

.frame::-webkit-scrollbar:horizontal {
    height: 11px;
}

.frame::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 2px solid white;
    background-color: rgba(0, 0, 0, .5);
}

.frame::-webkit-scrollbar-track {
    background-color: #fff;
    border-radius: 8px;
}
Copy after login

Conclusion:

By implementing this CSS styling, we can ensure that scroll bars remain visible for Mac trackpad users in WebKit/Blink browsers, providing a consistent and intuitive scrolling experience.

The above is the detailed content of How Can I Prevent Scroll Bars from Disappearing on My Mac Trackpad When Using WebKit/Blink Browsers?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template