Home >Web Front-end >CSS Tutorial >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; }
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; }
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!