diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index d091cc0c0965b..ab52475172333 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -184,6 +184,25 @@ nav.sub {
overflow: auto;
}
+/* Improve the scrollbar display on firefox */
+* {
+ scrollbar-width: initial;
+}
+.sidebar {
+ scrollbar-width: thin;
+}
+
+/* Improve the scrollbar display on webkit-based browsers */
+::-webkit-scrollbar {
+ width: 12px;
+}
+.sidebar::-webkit-scrollbar {
+ width: 8px;
+}
+::-webkit-scrollbar-track {
+ -webkit-box-shadow: inset 0;
+}
+
.sidebar .block > ul > li {
margin-right: -10px;
}
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index ff32a0fa09e4d..a2986c7b927e2 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -32,6 +32,28 @@ pre {
background-color: #505050;
}
+/* Improve the scrollbar display on firefox */
+* {
+ scrollbar-color: rgb(64, 65, 67) #717171;
+}
+.sidebar {
+ scrollbar-color: rgba(32,34,37,.6) transparent;
+}
+
+/* Improve the scrollbar display on webkit-based browsers */
+::-webkit-scrollbar-track {
+ background-color: #717171;
+}
+::-webkit-scrollbar-thumb {
+ background-color: rgba(32, 34, 37, .6);
+}
+.sidebar::-webkit-scrollbar-track {
+ background-color: #717171;
+}
+.sidebar::-webkit-scrollbar-thumb {
+ background-color: rgba(32, 34, 37, .6);
+}
+
.sidebar .current {
background-color: #333;
}
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index 2b2819f7126b4..be173d8eb46d3 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -34,6 +34,29 @@ pre {
background-color: #F1F1F1;
}
+/* Improve the scrollbar display on firefox */
+* {
+ scrollbar-color: rgba(36, 37, 39, 0.6) #e6e6e6;
+}
+
+.sidebar {
+ scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9;
+}
+
+/* Improve the scrollbar display on webkit-based browsers */
+::-webkit-scrollbar-track {
+ background-color: #ecebeb;
+}
+::-webkit-scrollbar-thumb {
+ background-color: rgba(36, 37, 39, 0.6);
+}
+.sidebar::-webkit-scrollbar-track {
+ background-color: #dcdcdc;
+}
+.sidebar::-webkit-scrollbar-thumb {
+ background-color: rgba(36, 37, 39, 0.6);
+}
+
.sidebar .current {
background-color: #fff;
}