質問編集履歴

1

コードを記載しました

2018/12/25 09:02

投稿

hahp
hahp

スコア10

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,304 @@
20
20
 
21
21
 
22
22
 
23
+ コード:
24
+
25
+ [html]
26
+
27
+ <body>
28
+
29
+ <div class="container-fluid">
30
+
31
+ <nav class="navbar navbar-default fixed-top">
32
+
33
+ <div class="navbar-header">
34
+
35
+ <a class="navbar-brand" href="#"><img class="img-responsive" src="images/logo/logo.png" width="200" alt=""/></a>
36
+
37
+ </div>
38
+
39
+ <ul class="nav navbar-nav navbar-right">
40
+
41
+ <!-- Use any element to open the sidenav -->
42
+
43
+ <span style="font-size:25px; color: #FF6600; cursor:pointer" onclick="openNav()">Menu &nbsp; &#9776;</span></ul>
44
+
45
+
46
+
47
+ <div id="mySidenav" class="sidenav">
48
+
49
+ <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
50
+
51
+ <button class="accordion">About</button>
52
+
53
+ <div class="panel"><a href="#">Organization</a></div>
54
+
55
+ <div class="panel"><a href="#">Artists</a></div>
56
+
57
+ <button class="accordion">Events</button>
58
+
59
+ <div class="panel"><a href="#">Upcoming</a></div>
60
+
61
+ <div class="panel"><a href="#">Past</a></div>
62
+
63
+ <button class="accordion">Classes</button>
64
+
65
+ <div class="panel"><a href="#">Class</a></div>
66
+
67
+ <a href="#">Contact</a>
68
+
69
+ </div>
70
+
71
+ </nav>
72
+
73
+ </div>
74
+
75
+ </body>
76
+
77
+
78
+
79
+ [css]
80
+
81
+ /* The side navigation menu */
82
+
83
+ .sidenav {
84
+
85
+ height: 100%; /* 100% Full-height */
86
+
87
+ width: 0; /* 0 width - change this with JavaScript */
88
+
89
+ position: fixed; /* Stay in place */
90
+
91
+ z-index: 1; /* Stay on top */
92
+
93
+ top: 0; /* Stay at the top */
94
+
95
+ right: 0;
96
+
97
+ background-color: #FFF6F0; /* Light orange*/
98
+
99
+ overflow-x: hidden; /* Disable horizontal scroll */
100
+
101
+ padding-top: 60px; /* Place content 60px from the top */
102
+
103
+ transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */
104
+
105
+ }
106
+
107
+
108
+
109
+ /* The navigation menu links */
110
+
111
+ .sidenav a {
112
+
113
+ padding: 8px 8px 8px 32px;
114
+
115
+ text-decoration: none;
116
+
117
+ font-size: 21px;
118
+
119
+ color: #707070;
120
+
121
+ display: block;
122
+
123
+ transition: 0.3s;
124
+
125
+ }
126
+
127
+
128
+
129
+ /* When you mouse over the navigation links, change their color */
130
+
131
+ .sidenav a:hover {
132
+
133
+ color: #FF6600;
134
+
135
+ }
136
+
137
+
138
+
139
+ /* Position and style the close button (top right corner) */
140
+
141
+ .sidenav .closebtn {
142
+
143
+ position: absolute;
144
+
145
+ top: 0;
146
+
147
+ right: 25px;
148
+
149
+ font-size: 36px;
150
+
151
+ margin-left: 50px;
152
+
153
+ }
154
+
155
+
156
+
157
+ /* Style page content - use this if you want to push the page content to the right when you open the side navigation */
158
+
159
+ #main {
160
+
161
+ transition: margin-left .5s;
162
+
163
+ padding: 20px;
164
+
165
+ }
166
+
167
+
168
+
169
+ /* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */
170
+
171
+ @media screen and (max-height: 450px) {
172
+
173
+ .sidenav {padding-top: 15px;}
174
+
175
+ .sidenav a {font-size: 18px;}
176
+
177
+ }
178
+
179
+
180
+
181
+ .accordion {
182
+
183
+ color: #55555;
184
+
185
+ background-color: none;
186
+
187
+ cursor: pointer;
188
+
189
+ padding: 0px;
190
+
191
+ width: 100%;
192
+
193
+ font-size: 15px;
194
+
195
+ transition: 0.4s;
196
+
197
+ }
198
+
199
+
200
+
201
+ .active, .accordion:hover {
202
+
203
+ color: #FF6600;
204
+
205
+ }
206
+
207
+
208
+
209
+ .accordion:after {
210
+
211
+ content: '\002B';
212
+
213
+ color: #FF6600;
214
+
215
+ font-weight: bold;
216
+
217
+ float: right;
218
+
219
+ margin-left: 5px;
220
+
221
+ }
222
+
223
+
224
+
225
+ .active:after {
226
+
227
+ content: "\2212";
228
+
229
+ }
230
+
231
+
232
+
233
+ .panel {
234
+
235
+ padding: 0px;
236
+
237
+ background-color: none;
238
+
239
+ max-height: 0;
240
+
241
+ overflow: hidden;
242
+
243
+ transition: max-height 0.2s ease-out;
244
+
245
+ }
246
+
247
+
248
+
249
+ [javascript]
250
+
251
+ 個々に分けて、bodyの最後に入れました。
252
+
253
+
254
+
255
+ <script src="/js/accordion.js"></script>
256
+
257
+ <script src="/js/menu.js"></script>
258
+
259
+
260
+
261
+ [menu]
262
+
263
+ /* Set the width of the side navigation to 250px */
264
+
265
+ function openNav() {
266
+
267
+ document.getElementById("mySidenav").style.width = "350px";
268
+
269
+ }
270
+
271
+
272
+
273
+ /* Set the width of the side navigation to 0 */
274
+
275
+ function closeNav() {
276
+
277
+ document.getElementById("mySidenav").style.width = "0";
278
+
279
+ }
280
+
281
+ // JavaScript Document
282
+
283
+
284
+
285
+ [accordion]
286
+
287
+ // JavaScript Document
288
+
289
+ var acc = document.getElementsByClassName("accordionmenu");
290
+
291
+ var i;
292
+
293
+
294
+
295
+ for (i = 0; i < acc.length; i++) {
296
+
297
+ acc[i].addEventListener("click", function() {
298
+
299
+ this.classList.toggle("active");
300
+
301
+ var panel = this.nextElementSibling;
302
+
303
+ if (panel.style.maxHeight){
304
+
305
+ panel.style.maxHeight = null;
306
+
307
+ } else {
308
+
309
+ panel.style.maxHeight = panel.scrollHeight + "px";
310
+
311
+ }
312
+
313
+ });
314
+
315
+ }
316
+
317
+
318
+
319
+
320
+
23
321
  Bootstrap のCSSかJavascriptが重複しているのでしょうか?
24
322
 
25
323