質問編集履歴
1
コードへ追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,18 +4,116 @@
|
|
4
4
|
実際にresizeで出来るのかすらあまりわかっていないそんな状態です。
|
5
5
|
|
6
6
|
```JavaScript
|
7
|
-
if
|
7
|
+
if(window.matchMedia('(min-width:1200px)').matches) {
|
8
|
+
//画面幅が992px以上の場合のみ有効。ページ更新時のWindow幅で判断。
|
8
9
|
$(function() {
|
10
|
+
$('#room-search').hide();
|
11
|
+
var gnavi = $('#header-mid');
|
12
|
+
var gnaviTop = gnavi.offset().top;
|
13
|
+
var gnaviHeight = gnavi.height();
|
14
|
+
var bottom = $('#header-bottom');
|
15
|
+
var bottomTop = bottom.offset().top;
|
16
|
+
var bottomHeight = bottom.height();
|
17
|
+
bottom.css('top', -bottomHeight+'px');
|
18
|
+
$(window).scroll(function () {
|
19
|
+
//TOPから460pxスクロールしたときにroom-searchをほわっと出力。460px未満で隠す。
|
20
|
+
if($(this).scrollTop() <= 460 && !$('#room-search').is(':hidden')){
|
21
|
+
$('#room-search').hide();
|
22
|
+
}else if($(this).scrollTop() > 460 && $('#room-search').is(':hidden')){
|
23
|
+
$('#room-search').fadeIn("slow");
|
24
|
+
}
|
25
|
+
if(($(this).scrollTop() - gnaviTop) < 0){
|
26
|
+
//header-midがウィンドウ上部から離れたときの動作をしたときに適応
|
27
|
+
gnavi.height(gnaviHeight);
|
28
|
+
$('#global-navi li a').css({'padding' : '25px 35px'});
|
29
|
+
gnavi.css({position:"static", top: "auto"});
|
30
|
+
bottom.css({position:"static", top: "auto"});
|
31
|
+
bottom.removeClass('header-shadow');
|
32
|
+
}else if(($(this).scrollTop() - gnaviTop) < 55){
|
9
|
-
|
33
|
+
//header-midがウィンドウ上部に触れたときの動作
|
34
|
+
gnavi.height((gnaviTop+gnaviHeight+4) - $(this).scrollTop());
|
35
|
+
gnavi.css({position:"fixed", top: 0});
|
36
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
37
|
+
bottom.removeClass('header-shadow');
|
38
|
+
$('#global-navi li a').css({'padding' : ((gnavi.height() -20)/2)+'px 35px'});
|
39
|
+
}else{
|
40
|
+
//ヘッダーに固定されたときheader-midの高さ30px確保し、ナビメニューの余白を上下5px左右20px保持
|
41
|
+
gnavi.height(30);
|
42
|
+
$('#global-navi li a').css({'padding' : '5px 35px'});
|
43
|
+
gnavi.css({position:"fixed", top: 0});
|
44
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
45
|
+
bottom.addClass('header-shadow');
|
46
|
+
}
|
10
47
|
});
|
11
48
|
});
|
12
|
-
}else if (window.matchMedia('
|
49
|
+
}else if (window.matchMedia('(min-width:991px) and (max-width: 1200px)').matches) {
|
13
50
|
$(function() {
|
14
|
-
|
51
|
+
$('#room-search').hide();
|
52
|
+
var gnavi = $('#header-mid');
|
53
|
+
var gnaviTop = gnavi.offset().top;
|
54
|
+
var gnaviHeight = gnavi.height();
|
55
|
+
var bottom = $('#header-bottom');
|
56
|
+
var bottomTop = bottom.offset().top;
|
57
|
+
var bottomHeight = bottom.height();
|
58
|
+
bottom.css('top', -bottomHeight+'px');
|
59
|
+
$(window).scroll(function () {
|
60
|
+
if($(this).scrollTop() <= 460 && !$('#room-search').is(':hidden')){
|
61
|
+
$('#room-search').hide();
|
62
|
+
}else if($(this).scrollTop() > 460 && $('#room-search').is(':hidden')){
|
63
|
+
$('#room-search').fadeIn("slow");
|
64
|
+
}
|
65
|
+
if(($(this).scrollTop() - gnaviTop) < 0){
|
66
|
+
gnavi.height(gnaviHeight);
|
67
|
+
$('#global-navi li a').css({'padding' : '30px 20px'});
|
68
|
+
gnavi.css({position:"static", top: "auto"});
|
69
|
+
bottom.css({position:"static", top: "auto"});
|
70
|
+
bottom.removeClass('header-shadow');
|
71
|
+
}else if(($(this).scrollTop() - gnaviTop) < 55){
|
72
|
+
gnavi.height((gnaviTop+gnaviHeight+4) - $(this).scrollTop());
|
73
|
+
gnavi.css({position:"fixed", top: 0});
|
74
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
75
|
+
bottom.removeClass('header-shadow');
|
76
|
+
$('#global-navi li a').css({'padding' : ((gnavi.height() -20)/2)+'px 20px'});
|
77
|
+
}else{
|
78
|
+
gnavi.height(30);
|
79
|
+
$('#global-navi li a').css({'padding' : '5px 20px'});
|
80
|
+
gnavi.css({position:"fixed", top: 0});
|
81
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
82
|
+
bottom.addClass('header-shadow');
|
83
|
+
}
|
84
|
+
});
|
15
85
|
});
|
16
86
|
}else{
|
17
87
|
$(function() {
|
18
|
-
|
88
|
+
$('#room-search').hide();
|
89
|
+
var gnavi = $('#header-mid');
|
90
|
+
var gnaviTop = gnavi.offset().top;
|
91
|
+
var gnaviHeight = gnavi.height();
|
92
|
+
var bottom = $('#header-bottom');
|
93
|
+
var bottomTop = bottom.offset().top;
|
94
|
+
var bottomHeight = bottom.height();
|
95
|
+
bottom.css('top', -bottomHeight+'px');
|
96
|
+
$(window).scroll(function () {
|
97
|
+
if(($(this).scrollTop() - gnaviTop) < 0){
|
98
|
+
gnavi.height(gnaviHeight);
|
99
|
+
$('#global-navi li a').css({'padding' : '30px 20px'});
|
100
|
+
gnavi.css({position:"static", top: "auto"});
|
101
|
+
bottom.css({position:"static", top: "auto"});
|
102
|
+
bottom.removeClass('header-shadow');
|
103
|
+
}else if(($(this).scrollTop() - gnaviTop) < 55){
|
104
|
+
gnavi.height((gnaviTop+gnaviHeight) - $(this).scrollTop());
|
105
|
+
gnavi.css({position:"fixed", top: 0});
|
106
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
107
|
+
bottom.removeClass('header-shadow');
|
108
|
+
$('#global-navi li a').css({'padding' : ((gnavi.height() -20)/2)+'px 20px'});
|
109
|
+
}else{
|
110
|
+
gnavi.height(30);
|
111
|
+
$('#global-navi li a').css({'padding' : '5px 20px'});
|
112
|
+
gnavi.css({position:"fixed", top: 0});
|
113
|
+
bottom.css({position:"fixed", top: gnavi.height()});
|
114
|
+
bottom.addClass('header-shadow');
|
115
|
+
}
|
116
|
+
});
|
19
117
|
});
|
20
118
|
}
|
21
119
|
```
|