diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css
index e531e6ce6bb..e82ec042637 100644
--- a/src/librustdoc/html/static/css/settings.css
+++ b/src/librustdoc/html/static/css/settings.css
@@ -41,9 +41,7 @@
.toggle {
position: relative;
- display: inline-block;
width: 100%;
- height: 27px;
margin-right: 20px;
display: flex;
align-items: center;
@@ -58,6 +56,7 @@
.slider {
position: relative;
width: 45px;
+ min-width: 45px;
display: block;
height: 28px;
margin-right: 20px;
diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml
index 8a3365d3cc2..d9cf5ee6614 100644
--- a/src/test/rustdoc-gui/settings.goml
+++ b/src/test/rustdoc-gui/settings.goml
@@ -147,3 +147,12 @@ assert-false: "noscript section"
javascript: false
reload:
assert-css: ("noscript section", {"display": "block"})
+javascript: true
+
+// Check for the display on small screen
+show-text: true
+reload:
+size: (300, 1000)
+click: "#settings-menu"
+wait-for: "#settings"
+assert-css: ("#settings .slider", {"width": "45px"}, ALL)