質問編集履歴
2
ソースコードを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,3 +11,231 @@
|
|
11
11
|
どうしても対応させたく様々なプラグインを試してみたのですが、挙動がおかしくなってしまったので、`position: sticky;`を使用しないで押し出される方法にしたいです。
|
12
12
|
|
13
13
|
なるべく自分で考えようと思い、`positon: relative;`と`positon: fixed;`をjsで制御させて実装しようと思ったのですが、上手くできなかったので、こちらで質問させて頂きます。(質問丸投げになってしまい、申し訳ありません。。)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```html
|
18
|
+
|
19
|
+
<div class="container">
|
20
|
+
|
21
|
+
<div class="cont1">
|
22
|
+
|
23
|
+
<div class="drop-img drop-img2">
|
24
|
+
|
25
|
+
<img src="https://dl.dropbox.com/s/rkox4afc0kmkfj1/drop.png?dl=0" alt="">
|
26
|
+
|
27
|
+
<p class="drop-year">
|
28
|
+
|
29
|
+
2019
|
30
|
+
|
31
|
+
</p>
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="cont2">
|
38
|
+
|
39
|
+
<div class="drop-img drop-img3">
|
40
|
+
|
41
|
+
<img src="https://dl.dropbox.com/s/rkox4afc0kmkfj1/drop.png?dl=0" alt="">
|
42
|
+
|
43
|
+
<p class="drop-year">
|
44
|
+
|
45
|
+
2018
|
46
|
+
|
47
|
+
</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div class="cont3">
|
54
|
+
|
55
|
+
<div class="drop-img">
|
56
|
+
|
57
|
+
<img src="https://dl.dropbox.com/s/rkox4afc0kmkfj1/drop.png?dl=0" alt="">
|
58
|
+
|
59
|
+
<p class="drop-year">
|
60
|
+
|
61
|
+
2017
|
62
|
+
|
63
|
+
</p>
|
64
|
+
|
65
|
+
</div>
|
66
|
+
|
67
|
+
</div>
|
68
|
+
|
69
|
+
<div class="cont4">
|
70
|
+
|
71
|
+
<div class="drop-img">
|
72
|
+
|
73
|
+
<img src="https://dl.dropbox.com/s/rkox4afc0kmkfj1/drop.png?dl=0" alt="">
|
74
|
+
|
75
|
+
<p class="drop-year">
|
76
|
+
|
77
|
+
2016
|
78
|
+
|
79
|
+
</p>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
```css
|
90
|
+
|
91
|
+
.container {
|
92
|
+
|
93
|
+
position: relative;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
&::before {
|
98
|
+
|
99
|
+
content: '';
|
100
|
+
|
101
|
+
position: absolute;
|
102
|
+
|
103
|
+
left: 0;
|
104
|
+
|
105
|
+
right: 0;
|
106
|
+
|
107
|
+
background: #00a0e9;
|
108
|
+
|
109
|
+
width: 3px;
|
110
|
+
|
111
|
+
height: 100%;
|
112
|
+
|
113
|
+
margin: auto;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
.drop {
|
122
|
+
|
123
|
+
&-img {
|
124
|
+
|
125
|
+
position: sticky;
|
126
|
+
|
127
|
+
top: 45%;
|
128
|
+
|
129
|
+
text-align: center;
|
130
|
+
|
131
|
+
right: 0;
|
132
|
+
|
133
|
+
left: 0;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
img {
|
138
|
+
|
139
|
+
width: 80px;
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
&-year {
|
148
|
+
|
149
|
+
position: absolute;
|
150
|
+
|
151
|
+
color: #fff;
|
152
|
+
|
153
|
+
left: 0;
|
154
|
+
|
155
|
+
right: 0;
|
156
|
+
|
157
|
+
top: 20px;
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
.cont1 {
|
166
|
+
|
167
|
+
background: #FFDEFF;
|
168
|
+
|
169
|
+
height: 600px;
|
170
|
+
|
171
|
+
text-align: center;
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
.cont2 {
|
178
|
+
|
179
|
+
background: #DEFFFF;
|
180
|
+
|
181
|
+
height: 600px;
|
182
|
+
|
183
|
+
text-align: center;
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
.cont3 {
|
190
|
+
|
191
|
+
background: #FFFFDE;
|
192
|
+
|
193
|
+
height: 600px;
|
194
|
+
|
195
|
+
text-align: center;
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
.cont4 {
|
202
|
+
|
203
|
+
background: #C7FFC7;
|
204
|
+
|
205
|
+
height: 600px;
|
206
|
+
|
207
|
+
text-align: center;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
```
|
214
|
+
|
215
|
+
```js
|
216
|
+
|
217
|
+
$(function() {
|
218
|
+
|
219
|
+
$(window).scroll(function() {
|
220
|
+
|
221
|
+
var wH = $(window).height();
|
222
|
+
|
223
|
+
var dropH = $('.drop-img').offset().top;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
if ( dropH < $(window).scrollTop() + (wH/2)) {
|
228
|
+
|
229
|
+
$('.drop-img').children('img').attr('src', 'https://dl.dropbox.com/s/ns0be5m1vp0611t/drop_gray.png?dl=0');
|
230
|
+
|
231
|
+
} else {
|
232
|
+
|
233
|
+
$('.drop-img').children('img').attr('src', 'https://dl.dropbox.com/s/rkox4afc0kmkfj1/drop.png?dl=0');
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
})
|
238
|
+
|
239
|
+
});
|
240
|
+
|
241
|
+
```
|
1
urlをクリックでジャンプできるようにした
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
https://codepen.io/yutas01/pen/povgqez
|
1
|
+
[https://codepen.io/yutas01/pen/povgqez](https://codepen.io/yutas01/pen/povgqez)
|
2
2
|
|
3
3
|
|
4
4
|
|