Skip to content

Commit dde3611

Browse files
Fix rendering issues on mobile
1 parent 56733bc commit dde3611

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/librustdoc/html/static/main.js

+26
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
// 2 for "In Return Types"
4848
var currentTab = 0;
4949

50+
var themesWidth = null;
51+
5052
function hasClass(elem, className) {
5153
if (elem && className && elem.className) {
5254
var elemClass = elem.className;
@@ -121,10 +123,25 @@
121123
sidebar.appendChild(div);
122124
}
123125
}
126+
var themeChoices = document.getElementById("theme-choices");
127+
if (themeChoices) {
128+
if (!themesWidth) {
129+
var savedState = themeChoices.style.display;
130+
themeChoices.style.display = 'block';
131+
themesWidth = themeChoices.offsetWidth + 'px';
132+
themeChoices.style.display = savedState;
133+
}
134+
themeChoices.style.position = "fixed";
135+
themeChoices.style.width = themesWidth;
136+
themeChoices.style.top = '78px';
137+
themeChoices.style.left = '250px';
138+
}
124139
document.getElementsByTagName("body")[0].style.marginTop = '45px';
125140
var themePicker = document.getElementById("theme-picker");
126141
if (themePicker) {
127142
themePicker.style.position = "fixed";
143+
themePicker.style.top = "50px";
144+
themePicker.style.left = "250px";
128145
}
129146
}
130147

@@ -143,6 +160,15 @@
143160
var themePicker = document.getElementById("theme-picker");
144161
if (themePicker) {
145162
themePicker.style.position = "absolute";
163+
themePicker.style.top = null;
164+
themePicker.style.left = null;
165+
}
166+
var themeChoices = document.getElementById("theme-choices");
167+
if (themeChoices) {
168+
themeChoices.style.position = 'absolute';
169+
themeChoices.style.width = null;
170+
themeChoices.style.top = null;
171+
themeChoices.style.left = null;
146172
}
147173
}
148174

src/librustdoc/html/static/rustdoc.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ span.since {
856856
display: block;
857857
border-bottom: 1px solid;
858858
border-right: 1px solid;
859+
height: 45px;
859860
}
860861

861862
.sidebar-elems {
@@ -875,7 +876,8 @@ span.since {
875876
}
876877

877878
nav.sub {
878-
margin: 0 auto;
879+
width: calc(100% - 32px);
880+
float: right;
879881
}
880882

881883
.content {
@@ -1184,8 +1186,8 @@ kbd {
11841186

11851187
@media (max-width: 700px) {
11861188
.theme-picker {
1187-
left: 109px;
1188-
top: 7px;
1189+
left: 10px;
1190+
top: 54px;
11891191
z-index: 1;
11901192
}
11911193
}

src/librustdoc/html/static/themes/dark.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,6 @@ kbd {
383383

384384
@media (max-width: 700px) {
385385
#theme-picker {
386-
background: #353535;
386+
background: #f0f0f0;
387387
}
388388
}

0 commit comments

Comments
 (0)