質問編集履歴
4
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
<style>
|
22
22
|
|
23
|
-
|
23
|
+
#menu-wrap {
|
24
24
|
|
25
25
|
position: fixed;
|
26
26
|
|
@@ -262,7 +262,7 @@
|
|
262
262
|
|
263
263
|
<body>
|
264
264
|
|
265
|
-
<div
|
265
|
+
<div id="menu-wrap">
|
266
266
|
|
267
267
|
<a class="menu-trigger"> <span></span> <span></span> <span></span> </a>
|
268
268
|
|
3
記述を修正致しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,35 +6,223 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
```html
|
10
|
+
|
11
|
+
<!doctype html>
|
12
|
+
|
13
|
+
<html>
|
14
|
+
|
15
|
+
<head>
|
16
|
+
|
17
|
+
<meta charset="UTF-8">
|
18
|
+
|
19
|
+
<title>無題ドキュメント</title>
|
20
|
+
|
21
|
+
<style>
|
22
|
+
|
23
|
+
.nav_container {
|
24
|
+
|
25
|
+
position: fixed;
|
26
|
+
|
27
|
+
top: 0;
|
28
|
+
|
29
|
+
width: 100%;
|
30
|
+
|
31
|
+
height: 50px;
|
32
|
+
|
33
|
+
z-index: 19;
|
34
|
+
|
35
|
+
background-color: #61a951;
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
.menu-trigger, .menu-trigger span {
|
40
|
+
|
41
|
+
display: inline-block;
|
42
|
+
|
43
|
+
transition: all .4s;
|
44
|
+
|
45
|
+
box-sizing: border-box;
|
46
|
+
|
47
|
+
cursor : pointer;
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
.menu-trigger {
|
52
|
+
|
53
|
+
position: fixed;
|
54
|
+
|
55
|
+
top: -5px;
|
56
|
+
|
57
|
+
right: 10px;
|
58
|
+
|
59
|
+
width: 35px;
|
60
|
+
|
61
|
+
height: 56px;
|
62
|
+
|
63
|
+
z-index: 20;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
.menu-trigger span {
|
68
|
+
|
69
|
+
position: absolute;
|
70
|
+
|
71
|
+
background: #fff;
|
72
|
+
|
73
|
+
width: 35px;
|
74
|
+
|
75
|
+
height: 2px;
|
76
|
+
|
77
|
+
margin: auto;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
.menu-trigger span:nth-of-type(1) {
|
82
|
+
|
83
|
+
top: 15px;
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
.menu-trigger span:nth-of-type(2) {
|
88
|
+
|
89
|
+
top: 0;
|
90
|
+
|
91
|
+
bottom: 0;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
.menu-trigger span:nth-of-type(3) {
|
96
|
+
|
97
|
+
bottom: 15px;
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
.menu-trigger.active span:nth-of-type(1) {
|
102
|
+
|
103
|
+
-webkit-transform: translateY(12px) rotate(-45deg);
|
104
|
+
|
105
|
+
transform: translateY(12px) rotate(-45deg);
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
.menu-trigger.active span:nth-of-type(2) {
|
110
|
+
|
111
|
+
opacity: 0;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
.menu-trigger.active span:nth-of-type(3) {
|
116
|
+
|
117
|
+
-webkit-transform: translateY(-12px) rotate(45deg);
|
118
|
+
|
119
|
+
transform: translateY(-12px) rotate(45deg);
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
.g-nav {
|
124
|
+
|
125
|
+
display: none;
|
126
|
+
|
127
|
+
position: fixed;
|
128
|
+
|
129
|
+
top: 0;
|
130
|
+
|
131
|
+
right: 0;
|
132
|
+
|
133
|
+
background:#ccc;
|
134
|
+
|
135
|
+
width: 100%;
|
136
|
+
|
137
|
+
height: 80%;
|
138
|
+
|
139
|
+
opacity: .98;
|
140
|
+
|
141
|
+
z-index: 10;
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
.list {
|
146
|
+
|
147
|
+
padding: 0px;
|
148
|
+
|
149
|
+
width: 80%;
|
150
|
+
|
151
|
+
margin: 10px auto;
|
152
|
+
|
153
|
+
margin-top: 10px;
|
154
|
+
|
155
|
+
list-style: none;
|
156
|
+
|
157
|
+
overflow-y: scroll;
|
158
|
+
|
159
|
+
-webkit-overflow-scrolling: touch;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
.list .item {
|
164
|
+
|
165
|
+
border-bottom: 1px solid #000;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
.item a {
|
170
|
+
|
171
|
+
display: block;
|
172
|
+
|
173
|
+
text-decoration: none;
|
174
|
+
|
175
|
+
color: #000;
|
176
|
+
|
177
|
+
padding: 25px 0 5px;
|
178
|
+
|
179
|
+
font-size: 1rem;
|
180
|
+
|
181
|
+
font-weight: 900;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
.cont{
|
186
|
+
|
187
|
+
width:100vw;
|
188
|
+
|
189
|
+
height:1000px;
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
</style>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
200
|
+
|
9
|
-
|
201
|
+
<script>
|
10
|
-
|
202
|
+
|
11
|
-
//
|
203
|
+
//ハンバーガーメニューのトリガー
|
204
|
+
|
12
|
-
|
205
|
+
$(function(){
|
206
|
+
|
13
|
-
|
207
|
+
$('.menu-trigger').on('click',function(){
|
208
|
+
|
14
|
-
|
209
|
+
$(this).toggleClass('active');
|
210
|
+
|
211
|
+
$('.g-nav').slideToggle();
|
212
|
+
|
213
|
+
});
|
214
|
+
|
215
|
+
});
|
216
|
+
|
15
|
-
//
|
217
|
+
//※ここが効かなくなる
|
16
218
|
|
17
219
|
$(function(){
|
18
220
|
|
19
|
-
var box = $("#menu-wrap");
|
20
|
-
|
21
|
-
var boxTop = box.offset().top;
|
22
|
-
|
23
|
-
$(
|
221
|
+
$('.list li').on('click', function() {
|
24
|
-
|
25
|
-
|
222
|
+
|
26
|
-
|
27
|
-
box.addClass("fixed");
|
28
|
-
|
29
|
-
$(
|
223
|
+
$('.menu-trigger').removeClass('active');
|
30
|
-
|
31
|
-
|
224
|
+
|
32
|
-
|
33
|
-
|
225
|
+
$('.g-nav').slideToggle();
|
34
|
-
|
35
|
-
$("body").css("margin-top","0px");
|
36
|
-
|
37
|
-
}
|
38
226
|
|
39
227
|
});
|
40
228
|
|
@@ -42,138 +230,78 @@
|
|
42
230
|
|
43
231
|
|
44
232
|
|
233
|
+
|
234
|
+
|
235
|
+
//ヘッダーの高さ分だけずらしてスクロール(ここを消すと※が動く)
|
236
|
+
|
45
|
-
$(function(){
|
237
|
+
$(function () {
|
238
|
+
|
46
|
-
|
239
|
+
var headerHight = $("#menu-wrap").height();
|
240
|
+
|
47
|
-
|
241
|
+
$('a[href^=#]').click(function(){
|
48
|
-
|
49
|
-
|
242
|
+
|
50
|
-
|
51
|
-
}, function(){
|
52
|
-
|
53
|
-
|
243
|
+
var href= $(this).attr("href");
|
54
|
-
|
244
|
+
|
55
|
-
|
245
|
+
var target = $(href == "#" || href == "" ? 'html' : href);
|
246
|
+
|
56
|
-
|
247
|
+
var position = target.offset().top-headerHight;
|
248
|
+
|
249
|
+
$("html, body").animate({scrollTop:position}, 550, "swing");
|
250
|
+
|
57
|
-
|
251
|
+
return false;
|
58
252
|
|
59
253
|
});
|
60
254
|
|
61
255
|
});
|
62
256
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
i
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
/
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
//※ここの部分が効きません
|
116
|
-
|
117
|
-
$(function(){
|
118
|
-
|
119
|
-
$('.list li').on('click', function() {
|
120
|
-
|
121
|
-
$('.menu-trigger').removeClass('active');
|
122
|
-
|
123
|
-
$('.g-nav').slideToggle();
|
124
|
-
|
125
|
-
});
|
126
|
-
|
127
|
-
});
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//ヘッダーの高さ分だけずらしてスクロール
|
134
|
-
|
135
|
-
$(function () {
|
136
|
-
|
137
|
-
var headerHight = $("#menu-wrap").height();
|
138
|
-
|
139
|
-
$('a[href^=#]').click(function(){
|
140
|
-
|
141
|
-
var href= $(this).attr("href");
|
142
|
-
|
143
|
-
var target = $(href == "#" || href == "" ? 'html' : href);
|
144
|
-
|
145
|
-
var position = target.offset().top-headerHight;
|
146
|
-
|
147
|
-
$("html, body").animate({scrollTop:position}, 550, "swing");
|
148
|
-
|
149
|
-
return false;
|
150
|
-
|
151
|
-
});
|
152
|
-
|
153
|
-
});
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
//ポップアップアニメーション
|
158
|
-
|
159
|
-
$(window).scroll(function() {
|
160
|
-
|
161
|
-
$('.animatedElement').each(function(){
|
162
|
-
|
163
|
-
var imagePos = $(this).offset().top;
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
var topOfWindow = $(window).scrollTop();
|
168
|
-
|
169
|
-
if (imagePos < topOfWindow+800) {
|
170
|
-
|
171
|
-
$(this).addClass("fadeIn");
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
});
|
176
|
-
|
177
|
-
});
|
257
|
+
</script>
|
258
|
+
|
259
|
+
</head>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<body>
|
264
|
+
|
265
|
+
<div class="nav_container">
|
266
|
+
|
267
|
+
<a class="menu-trigger"> <span></span> <span></span> <span></span> </a>
|
268
|
+
|
269
|
+
<nav class="g-nav">
|
270
|
+
|
271
|
+
<ul class="list">
|
272
|
+
|
273
|
+
<li class="item"><a href="#content_first">コンテンツ1</a></li>
|
274
|
+
|
275
|
+
<li class="item"><a href="#content_second">コンテンツ2</a></li>
|
276
|
+
|
277
|
+
<li class="item"><a href="#content_third">コンテンツ3</a></li>
|
278
|
+
|
279
|
+
<li class="item"><a href="#content_fourth">コンテンツ4</a></li>
|
280
|
+
|
281
|
+
</ul>
|
282
|
+
|
283
|
+
</nav>
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
<div id="content_first" class="cont">コンテンツ1
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div id="content_second" class="cont">コンテンツ2
|
292
|
+
|
293
|
+
</div>
|
294
|
+
|
295
|
+
<div id="content_third" class="cont">コンテンツ3
|
296
|
+
|
297
|
+
</div>
|
298
|
+
|
299
|
+
<div id="content_fourth" class="cont">コンテンツ4
|
300
|
+
|
301
|
+
</div>
|
302
|
+
|
303
|
+
</body>
|
304
|
+
|
305
|
+
</html>
|
178
306
|
|
179
307
|
```
|
2
全てのjavascriptを追記致しました。宜しくお願いいたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,94 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
```javascript
|
10
|
+
|
11
|
+
// JavaScript Document
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
//ヘッダーをトップで固定pc用 スマホは固定分の隙間をなくす
|
16
|
+
|
17
|
+
$(function(){
|
18
|
+
|
19
|
+
var box = $("#menu-wrap");
|
20
|
+
|
21
|
+
var boxTop = box.offset().top;
|
22
|
+
|
23
|
+
$(window).scroll(function () {
|
24
|
+
|
25
|
+
if($(window).scrollTop() >= boxTop && !window.matchMedia('screen and (max-width: 780px)').matches){
|
26
|
+
|
27
|
+
box.addClass("fixed");
|
28
|
+
|
29
|
+
$("body").css("margin-top","8vw");
|
30
|
+
|
31
|
+
} else {
|
32
|
+
|
33
|
+
box.removeClass("fixed");
|
34
|
+
|
35
|
+
$("body").css("margin-top","0px");
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
});
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
$(function(){
|
46
|
+
|
47
|
+
$('#menu img').hover(function(){
|
48
|
+
|
49
|
+
$(this).attr('src', $(this).attr('src').replace('_off', '_on'));
|
50
|
+
|
51
|
+
}, function(){
|
52
|
+
|
53
|
+
if (!$(this).hasClass('currentPage')) {
|
54
|
+
|
55
|
+
$(this).attr('src', $(this).attr('src').replace('_on', '_off'));
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
});
|
60
|
+
|
61
|
+
});
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
//サイドメニュー固定
|
68
|
+
|
69
|
+
jQuery(function($) {
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
var nav = $('.nav_side'),
|
74
|
+
|
75
|
+
offset = nav.offset();
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
$(window).scroll(function () {
|
80
|
+
|
81
|
+
if($(window).scrollTop() > offset.top - 100) {
|
82
|
+
|
83
|
+
nav.addClass('fixed_side');
|
84
|
+
|
85
|
+
} else {
|
86
|
+
|
87
|
+
nav.removeClass('fixed_side');
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
});
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
});
|
96
|
+
|
97
|
+
|
10
98
|
|
11
99
|
//ハンバーガーメニューのトリガー
|
12
100
|
|
@@ -24,7 +112,7 @@
|
|
24
112
|
|
25
113
|
|
26
114
|
|
27
|
-
//ここの部分が効
|
115
|
+
//※ここの部分が効きません
|
28
116
|
|
29
117
|
$(function(){
|
30
118
|
|
@@ -64,4 +152,28 @@
|
|
64
152
|
|
65
153
|
});
|
66
154
|
|
155
|
+
|
156
|
+
|
157
|
+
//ポップアップアニメーション
|
158
|
+
|
159
|
+
$(window).scroll(function() {
|
160
|
+
|
161
|
+
$('.animatedElement').each(function(){
|
162
|
+
|
163
|
+
var imagePos = $(this).offset().top;
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
var topOfWindow = $(window).scrollTop();
|
168
|
+
|
169
|
+
if (imagePos < topOfWindow+800) {
|
170
|
+
|
171
|
+
$(this).addClass("fadeIn");
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
});
|
178
|
+
|
67
179
|
```
|
1
質問の変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
スクリプトが競合しているとこを教えてください
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
スクロールのスクリプトを入れるとハンバーガーメニューが効かなくなってしましました。
|
2
2
|
|
3
|
-
|
3
|
+
何かが競合しているのでしょうか?
|
4
4
|
|
5
|
-
|
5
|
+
解決策をご教授お願いいたします。
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -24,6 +24,8 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
//ここの部分が効かなくなる
|
28
|
+
|
27
29
|
$(function(){
|
28
30
|
|
29
31
|
$('.list li').on('click', function() {
|
@@ -38,25 +40,27 @@
|
|
38
40
|
|
39
41
|
|
40
42
|
|
41
|
-
//スムーススクロール
|
42
43
|
|
43
|
-
$(function(){
|
44
44
|
|
45
|
-
|
45
|
+
//ヘッダーの高さ分だけずらしてスクロール
|
46
46
|
|
47
|
-
|
47
|
+
$(function () {
|
48
48
|
|
49
|
-
|
49
|
+
var headerHight = $("#menu-wrap").height();
|
50
50
|
|
51
|
-
|
51
|
+
$('a[href^=#]').click(function(){
|
52
52
|
|
53
|
-
var
|
53
|
+
var href= $(this).attr("href");
|
54
54
|
|
55
|
-
$("html
|
55
|
+
var target = $(href == "#" || href == "" ? 'html' : href);
|
56
56
|
|
57
|
-
r
|
57
|
+
var position = target.offset().top-headerHight;
|
58
58
|
|
59
|
+
$("html, body").animate({scrollTop:position}, 550, "swing");
|
60
|
+
|
61
|
+
return false;
|
62
|
+
|
59
|
-
});
|
63
|
+
});
|
60
64
|
|
61
65
|
});
|
62
66
|
|