teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードを記載しました

2018/12/25 09:02

投稿

hahp
hahp

スコア10

title CHANGED
File without changes
body CHANGED
@@ -9,6 +9,155 @@
9
9
  結果:
10
10
  ![イメージ説明](d3e6b3854a1c7235d84af27525dbde95.png)
11
11
 
12
+ コード:
13
+ [html]
14
+ <body>
15
+ <div class="container-fluid">
16
+ <nav class="navbar navbar-default fixed-top">
17
+ <div class="navbar-header">
18
+ <a class="navbar-brand" href="#"><img class="img-responsive" src="images/logo/logo.png" width="200" alt=""/></a>
19
+ </div>
20
+ <ul class="nav navbar-nav navbar-right">
21
+ <!-- Use any element to open the sidenav -->
22
+ <span style="font-size:25px; color: #FF6600; cursor:pointer" onclick="openNav()">Menu &nbsp; &#9776;</span></ul>
23
+
24
+ <div id="mySidenav" class="sidenav">
25
+ <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
26
+ <button class="accordion">About</button>
27
+ <div class="panel"><a href="#">Organization</a></div>
28
+ <div class="panel"><a href="#">Artists</a></div>
29
+ <button class="accordion">Events</button>
30
+ <div class="panel"><a href="#">Upcoming</a></div>
31
+ <div class="panel"><a href="#">Past</a></div>
32
+ <button class="accordion">Classes</button>
33
+ <div class="panel"><a href="#">Class</a></div>
34
+ <a href="#">Contact</a>
35
+ </div>
36
+ </nav>
37
+ </div>
38
+ </body>
39
+
40
+ [css]
41
+ /* The side navigation menu */
42
+ .sidenav {
43
+ height: 100%; /* 100% Full-height */
44
+ width: 0; /* 0 width - change this with JavaScript */
45
+ position: fixed; /* Stay in place */
46
+ z-index: 1; /* Stay on top */
47
+ top: 0; /* Stay at the top */
48
+ right: 0;
49
+ background-color: #FFF6F0; /* Light orange*/
50
+ overflow-x: hidden; /* Disable horizontal scroll */
51
+ padding-top: 60px; /* Place content 60px from the top */
52
+ transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */
53
+ }
54
+
55
+ /* The navigation menu links */
56
+ .sidenav a {
57
+ padding: 8px 8px 8px 32px;
58
+ text-decoration: none;
59
+ font-size: 21px;
60
+ color: #707070;
61
+ display: block;
62
+ transition: 0.3s;
63
+ }
64
+
65
+ /* When you mouse over the navigation links, change their color */
66
+ .sidenav a:hover {
67
+ color: #FF6600;
68
+ }
69
+
70
+ /* Position and style the close button (top right corner) */
71
+ .sidenav .closebtn {
72
+ position: absolute;
73
+ top: 0;
74
+ right: 25px;
75
+ font-size: 36px;
76
+ margin-left: 50px;
77
+ }
78
+
79
+ /* Style page content - use this if you want to push the page content to the right when you open the side navigation */
80
+ #main {
81
+ transition: margin-left .5s;
82
+ padding: 20px;
83
+ }
84
+
85
+ /* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */
86
+ @media screen and (max-height: 450px) {
87
+ .sidenav {padding-top: 15px;}
88
+ .sidenav a {font-size: 18px;}
89
+ }
90
+
91
+ .accordion {
92
+ color: #55555;
93
+ background-color: none;
94
+ cursor: pointer;
95
+ padding: 0px;
96
+ width: 100%;
97
+ font-size: 15px;
98
+ transition: 0.4s;
99
+ }
100
+
101
+ .active, .accordion:hover {
102
+ color: #FF6600;
103
+ }
104
+
105
+ .accordion:after {
106
+ content: '\002B';
107
+ color: #FF6600;
108
+ font-weight: bold;
109
+ float: right;
110
+ margin-left: 5px;
111
+ }
112
+
113
+ .active:after {
114
+ content: "\2212";
115
+ }
116
+
117
+ .panel {
118
+ padding: 0px;
119
+ background-color: none;
120
+ max-height: 0;
121
+ overflow: hidden;
122
+ transition: max-height 0.2s ease-out;
123
+ }
124
+
125
+ [javascript]
126
+ 個々に分けて、bodyの最後に入れました。
127
+
128
+ <script src="/js/accordion.js"></script>
129
+ <script src="/js/menu.js"></script>
130
+
131
+ [menu]
132
+ /* Set the width of the side navigation to 250px */
133
+ function openNav() {
134
+ document.getElementById("mySidenav").style.width = "350px";
135
+ }
136
+
137
+ /* Set the width of the side navigation to 0 */
138
+ function closeNav() {
139
+ document.getElementById("mySidenav").style.width = "0";
140
+ }
141
+ // JavaScript Document
142
+
143
+ [accordion]
144
+ // JavaScript Document
145
+ var acc = document.getElementsByClassName("accordionmenu");
146
+ var i;
147
+
148
+ for (i = 0; i < acc.length; i++) {
149
+ acc[i].addEventListener("click", function() {
150
+ this.classList.toggle("active");
151
+ var panel = this.nextElementSibling;
152
+ if (panel.style.maxHeight){
153
+ panel.style.maxHeight = null;
154
+ } else {
155
+ panel.style.maxHeight = panel.scrollHeight + "px";
156
+ }
157
+ });
158
+ }
159
+
160
+
12
161
  Bootstrap のCSSかJavascriptが重複しているのでしょうか?
13
162
 
14
163
  その場合、どのように設計するのがよいか教えていただけると幸いです。