Home > Web Front-end > CSS Tutorial > How to Always Display the Vertical Scrollbar in WebKit Browsers?

How to Always Display the Vertical Scrollbar in WebKit Browsers?

Patricia Arquette
Release: 2024-12-06 19:06:16
Original
822 people have browsed it

How to Always Display the Vertical Scrollbar in WebKit Browsers?

Always Displaying Vertical Scroll Bar

In certain web designs, it's crucial to ensure users can easily identify scrollable content in a div element. Despite setting overflow-y: scroll, the vertical scroll bar may not be visible when not actively being used on certain operating systems, such as macOS.

Solution:

To force the vertical scroll bar to always display, use the following CSS properties:

::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 7px;
}

::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background-color: rgba(0, 0, 0, .5);
  box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}
Copy after login

These styles apply to the WebKit-based browsers, such as Safari and Chrome on macOS. By customizing the appearance of the scrollbar, you can make it more prominent and indicate the presence of scrollable content even when it's not in active use.

The above is the detailed content of How to Always Display the Vertical Scrollbar in WebKit 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