-
Hi, i want to customize style of scrollbar. In my case i want to make:
Currently i have this styles: .my-theme {
--os-size: 12px;
--os-track-border-radius: 0;
--os-track-bg: #f00;
--os-handle-border-radius: 2px;
--os-handle-bg: #0f0;
--os-handle-perpendicular-size: 4px;
--os-handle-perpendicular-size-hover: 4px;
--os-handle-perpendicular-size-active: 4px;
} Everything is fine except the handle is not centered: How can i properly make handle centered? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@krutoo I guess this is the same question as "how do I center a div".. You have many possibilities like using padding, using margin, using the inset and more. Please take a look at the styling section inside the README (https://github.com/KingSora/OverlayScrollbars#styling-in-depth) which explains how a scrollbar looks HTML wise and what the CSS selectors are. |
Beta Was this translation helpful? Give feedback.
-
@krutoo Here is an example of how I would handle it: https://stackblitz.com/edit/overlayscrollbars-react-5shnc9?file=src%2Findex.css .my-theme.os-scrollbar-horizontal .os-scrollbar-handle {
margin-bottom: calc(
var(--os-size) / 2 - var(--os-handle-perpendicular-size) / 2
);
}
.my-theme.os-scrollbar-vertical .os-scrollbar-handle {
margin-right: calc(
var(--os-size) / 2 - var(--os-handle-perpendicular-size) / 2
);
} |
Beta Was this translation helpful? Give feedback.
@krutoo Here is an example of how I would handle it: https://stackblitz.com/edit/overlayscrollbars-react-5shnc9?file=src%2Findex.css