Skip to content

Commit 331964e

Browse files
Ajacksteramueller
authored andcommitted
[MRG+1] DOC Modified the navbar menu to be responsive with mobile. (scikit-learn#7098)
* Modified the navbar menu to be responsive with mobile. * Gave the navbar a fixed height * Gave more padding to the hamburger * Fixed text overflow issue on mobile menu * Got rid of extra line * Made the whole hamburger clickable
1 parent 7161755 commit 331964e

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed

doc/themes/scikit-learn/layout.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
$(this).css('background-color', '#A7D6E2');
3939
}
4040
);
41+
function showMenu() {
42+
var topNav = document.getElementById("scikit-navbar");
43+
if (topNav.className === "navbar") {
44+
topNav.className += " responsive";
45+
} else {
46+
topNav.className = "navbar";
47+
}
48+
};
4149
</script>
4250
{% endblock %}
4351

@@ -61,7 +69,7 @@
6169
{%- endif %}
6270

6371
{%- block navbar -%}
64-
<div class="navbar">
72+
<div class="navbar" id="scikit-navbar">
6573
<ul>
6674
<li><a href="{{pathto('index')}}">Home</a></li>
6775
<li><a href="{{pathto('install')}}">Installation</a></li>
@@ -87,7 +95,13 @@
8795
</li>
8896
<li><a href="{{pathto('auto_examples/index')}}">Examples</a></li>
8997
</ul>
90-
98+
<a href="javascript:void(0);" onclick="showMenu()">
99+
<div class="nav-icon">
100+
<div class="hamburger-line"></div>
101+
<div class="hamburger-line"></div>
102+
<div class="hamburger-line"></div>
103+
</div>
104+
</a>
91105
<div class="search_form">
92106
<div id="cse" style="width: 100%;"></div>
93107
</div>

doc/themes/scikit-learn/static/nature.css_t

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ul.horizontal, ul.horizontal li {
4242
div.header {
4343
/* for the logo to correctly expand when showing results
4444
but remain cut when not */
45+
height: 60px;
4546
}
4647

4748

@@ -94,6 +95,105 @@ div.navbar ul li a:hover {
9495
color: #EEE;
9596
}
9697

98+
div.navbar div.nav-icon a,
99+
div.navbar div.nav-icon a:link,
100+
div.navbar div.nav-icon a:visited,
101+
div.navbar div.nav-icon a:hover {
102+
color: white;
103+
text-decoration: none;
104+
}
105+
div.navbar div.nav-icon {
106+
display: none;
107+
}
108+
/* Nav bar collapses for mobile phones and shows the hamburger */
109+
@media screen and (max-width: 680px) {
110+
div.navbar div.nav-icon {
111+
position: absolute;
112+
display: inline-block;
113+
right: 0;
114+
top: 12px;
115+
margin-right: 10px;
116+
background: #ff9c34;
117+
padding: 5px 10px;
118+
border-radius: 5px;
119+
}
120+
div.navbar ul li {
121+
display: none;
122+
}
123+
div.navbar ul {
124+
visibilty: hidden;
125+
background: #FFFFFF;
126+
}
127+
div.navbar.responsive > ul li.btn-li {
128+
margin-left: 6px;
129+
}
130+
div.navbar.responsive > ul li.btn-li + li {
131+
margin-top: -5px;
132+
}
133+
div.navbar.responsive > ul {
134+
visiblity: visible;
135+
position: absolute;
136+
right: 0;
137+
top: 10px;
138+
margin-right: 10px;
139+
background: #ff9c34;
140+
}
141+
div.navbar.responsive > ul li {
142+
display: flex;
143+
justify-content: flex-start;
144+
visibility: visible;
145+
width: 130px;
146+
}
147+
div.navbar .dropdown-menu li {
148+
white-space: normal;
149+
}
150+
div.navbar div.nav-icon .hamburger-line {
151+
background: white;
152+
width: 20px;
153+
height: 2px;
154+
margin-bottom: 5px;
155+
-webkit-transition: .1s ease-in-out;
156+
-moz-transition: .1s ease-in-out;
157+
-o-transition: .1s ease-in-out;
158+
transition: .1s ease-in-out;
159+
}
160+
div.navbar div.nav-icon .hamburger-line:nth-child(1) {
161+
margin-top: 5px;
162+
-webkit-transform-origin: left center;
163+
-moz-transform-origin: left center;
164+
-o-transform-origin: left center;
165+
transform-origin: left center;
166+
}
167+
div.navbar div.nav-icon .hamburger-line:nth-child(2) {
168+
-webkit-transform-origin: left center;
169+
-moz-transform-origin: left center;
170+
-o-transform-origin: left center;
171+
transform-origin: left center;
172+
}
173+
div.navbar div.nav-icon .hamburger-line:nth-child(3) {
174+
-webkit-transform-origin: left center;
175+
-moz-transform-origin: left center;
176+
-o-transform-origin: left center;
177+
transform-origin: left center;
178+
}
179+
div.navbar.responsive div.nav-icon .hamburger-line:nth-child(1) {
180+
-webkit-transform: rotate(45deg);
181+
-moz-transform: rotate(45deg);
182+
-o-transform: rotate(45deg);
183+
transform: rotate(45deg);
184+
}
185+
div.navbar.responsive div.nav-icon .hamburger-line:nth-child(2) {
186+
width: 0;
187+
opacity: 0%;
188+
}
189+
div.navbar.responsive div.nav-icon .hamburger-line:nth-child(3) {
190+
-webkit-transform: rotate(-45deg);
191+
-moz-transform: rotate(-45deg);
192+
-o-transform: rotate(-45deg);
193+
transform: rotate(-45deg);
194+
}
195+
}
196+
97197
/*-------------------------------------------------------------*/
98198
/* The next few elements have to do with the gsc (referring to */
99199
/* Google's custom search bar */

0 commit comments

Comments
 (0)