質問編集履歴
3
説明文を修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -296,7 +296,7 @@
|
|
296
296
|
}
|
297
297
|
```
|
298
298
|
|
299
|
-
追記:修正したjavascriptコードとクラス名を変更したのでHTMLファイルも再度掲載します。
|
299
|
+
追記:クラス定義を修正したjavascriptコードとクラス名を変更したのでHTMLファイルも再度掲載します。
|
300
300
|
```javaScript
|
301
301
|
let slideNumber = $('.contents').length;
|
302
302
|
let slideLarge = $('.contents').width();
|
2
修正したjavascriptコードとクラス名を変更したのでHTMLファイルも再度掲載
title
CHANGED
File without changes
|
body
CHANGED
@@ -294,4 +294,85 @@
|
|
294
294
|
.pagination a.active:before{
|
295
295
|
margin-left: -130px;
|
296
296
|
}
|
297
|
+
```
|
298
|
+
|
299
|
+
追記:修正したjavascriptコードとクラス名を変更したのでHTMLファイルも再度掲載します。
|
300
|
+
```javaScript
|
301
|
+
let slideNumber = $('.contents').length;
|
302
|
+
let slideLarge = $('.contents').width();
|
303
|
+
let slideContentsLarge = slideNumber * slideLarge;
|
304
|
+
|
305
|
+
console.log(slideNumber);
|
306
|
+
console.log(slideLarge);
|
307
|
+
console.log(slideContentsLarge);
|
308
|
+
|
309
|
+
slideNumber = 0;
|
310
|
+
|
311
|
+
class Slider {
|
312
|
+
constructor(slider, slidecontainer, contents, animationSpeed, interval){
|
313
|
+
this.slide = $("#"+slider);
|
314
|
+
this.slideContainer = $("."+slidecontainer);
|
315
|
+
this.contents = $("."+contents);
|
316
|
+
this.animationSpeed = animationSpeed;
|
317
|
+
this.interval = interval;
|
318
|
+
} //constructor
|
319
|
+
|
320
|
+
check(){
|
321
|
+
console.log($(this.slide).length);
|
322
|
+
console.log($(this.slideContainer).length);
|
323
|
+
console.log($(this.contents).length);
|
324
|
+
};
|
325
|
+
|
326
|
+
initSlide(){
|
327
|
+
$(this.contents).css('width', slideLarge);
|
328
|
+
$(this.slideContainer).css({
|
329
|
+
width: slideContentsLarge,
|
330
|
+
marginLeft: -slideLarge
|
331
|
+
});
|
332
|
+
|
333
|
+
// On insère la dernière slide au début de la Div.slide-container
|
334
|
+
$('.contents:last-child').prependTo($(this.slideContainer));
|
335
|
+
//prev
|
336
|
+
function moveGauche(){
|
337
|
+
slideNumber--;
|
338
|
+
$(this.slideContainer).animate({'left': slideLarge}, this.animationSpeed, function(){
|
339
|
+
$('.contents:last-child').prependTo($(this.slideContainer));
|
340
|
+
$(this.slideContainer).css('left', '');
|
341
|
+
});
|
342
|
+
}
|
343
|
+
//next
|
344
|
+
function moveDroite(){
|
345
|
+
slideNumber++;
|
346
|
+
$(this.slideContainer).animate({'left': -slideLarge}, this.animationSpeed, function(){
|
347
|
+
$('.contents:first-child').appendTo($(this.slideContainer));
|
348
|
+
$(this.slideContainer).css('left', '');
|
349
|
+
});
|
350
|
+
|
351
|
+
}
|
352
|
+
setInterval(moveDroite, this.interval);
|
353
|
+
} //initSlide()
|
354
|
+
|
355
|
+
} //class Slider
|
356
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
357
|
+
const sliderA = new Slider('slider', 'slidecontainer', 'contents', 300, 5000);
|
358
|
+
sliderA.initSlide();
|
359
|
+
sliderA.check();
|
360
|
+
});
|
361
|
+
```
|
362
|
+
|
363
|
+
```HTML
|
364
|
+
<section class="row" id="slider">
|
365
|
+
<div class="col-md-12 slide-view">
|
366
|
+
<div class="col-md-12 slidecontainer">
|
367
|
+
|
368
|
+
<div class="col-md-12 contents" id="slide01"></div>
|
369
|
+
<div class="col-md-12 contents" id="slide02"></div>
|
370
|
+
<div class="col-md-12 contents" id="slide03"></div>
|
371
|
+
<div class="col-md-12 contents" id="slide04"></div>
|
372
|
+
<div class="col-md-12 contents" id="slide05"></div>
|
373
|
+
<div class="col-md-12 contents" id="slide06"></div>
|
374
|
+
|
375
|
+
</div> <!--slidecontainer-->
|
376
|
+
</div> <!--slide-view-->
|
377
|
+
</section>
|
297
378
|
```
|
1
HTMLコードとCSSコードを追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -60,4 +60,238 @@
|
|
60
60
|
|
61
61
|
const slider = new Slider('slide', 'slideContainer', 'contents', 300, 5000);
|
62
62
|
slider.initSlide();
|
63
|
+
```
|
64
|
+
|
65
|
+
```HTML
|
66
|
+
<body>
|
67
|
+
<div class="container-fluid">
|
68
|
+
<section class="row" id="slider">
|
69
|
+
<div class="col-md-12 slide-container">
|
70
|
+
<div class="col-md-12 slide" id="slide06"></div>
|
71
|
+
<div class="col-md-12 slide" id="slide01"></div>
|
72
|
+
<div class="col-md-12 slide" id="slide02"></div>
|
73
|
+
<div class="col-md-12 slide" id="slide03"></div>
|
74
|
+
<div class="col-md-12 slide" id="slide04"></div>
|
75
|
+
<div class="col-md-12 slide" id="slide05"></div>
|
76
|
+
</div>
|
77
|
+
<div class="slider-navi">
|
78
|
+
<a href="#" class="arrow next"><i class="fas fa-arrow-right"></i></a>
|
79
|
+
<a href="#" class="arrow prev"><i class="fas fa-arrow-left"></i></a>
|
80
|
+
</div>
|
81
|
+
<div class="pagination"></div>
|
82
|
+
</section>
|
83
|
+
```
|
84
|
+
|
85
|
+
```CSS
|
86
|
+
#slider {
|
87
|
+
height: 500px;
|
88
|
+
width: 85%;
|
89
|
+
position: relative;
|
90
|
+
margin: auto;
|
91
|
+
box-shadow: 0 0 8px #404040;
|
92
|
+
}
|
93
|
+
|
94
|
+
.slide-view {
|
95
|
+
/*position: relative;*/
|
96
|
+
overflow: hidden;
|
97
|
+
height: 500px;
|
98
|
+
width: 100%;
|
99
|
+
}
|
100
|
+
|
101
|
+
.slide-container {
|
102
|
+
width: 600%;
|
103
|
+
height: 100%;
|
104
|
+
display: flex;
|
105
|
+
position: absolute;
|
106
|
+
left: 0;
|
107
|
+
}
|
108
|
+
|
109
|
+
.slide{
|
110
|
+
position: relative;
|
111
|
+
width: 100%;
|
112
|
+
height: 500px;
|
113
|
+
color: #fff;
|
114
|
+
/*float: left;*/
|
115
|
+
}
|
116
|
+
|
117
|
+
.slide a {
|
118
|
+
display: block;
|
119
|
+
}
|
120
|
+
|
121
|
+
.slide a:hover {
|
122
|
+
color: #600;
|
123
|
+
}
|
124
|
+
|
125
|
+
#slide01 {
|
126
|
+
background: linear-gradient(45deg, rgba(24, 24, 24, 0.9) 10%, rgba(255, 255, 255, 0.1) 55%),
|
127
|
+
url(images/bike-414278_1920.jpg) no-repeat 0px -120px;
|
128
|
+
}
|
129
|
+
|
130
|
+
#slide01 .text-container {
|
131
|
+
color: #fff;
|
132
|
+
top: 20%;
|
133
|
+
left: 50px;
|
134
|
+
}
|
135
|
+
|
136
|
+
#slide01 .text-container > h2 {
|
137
|
+
font-size: 3em;
|
138
|
+
font-family: 'latobold', Arial, sans-serif;
|
139
|
+
}
|
140
|
+
|
141
|
+
#slide01 .text-container > h1 {
|
142
|
+
font-size: 1.5em;
|
143
|
+
font-family: 'latoregular', Arial, sans-serif;
|
144
|
+
line-height: 1.5em;
|
145
|
+
}
|
146
|
+
|
147
|
+
/* slide 02 */
|
148
|
+
#slide02 {
|
149
|
+
background: linear-gradient(rgba(22, 129, 134, 0.7), rgba(22, 129, 134, 0.7)),
|
150
|
+
url(images/bike-414278_1920.jpg);
|
151
|
+
}
|
152
|
+
|
153
|
+
#slide02 .text-container,
|
154
|
+
#slide03 .text-container,
|
155
|
+
#slide04 .text-container,
|
156
|
+
#slide05 .text-container,
|
157
|
+
#slide06 .text-container
|
158
|
+
{
|
159
|
+
margin: 80px auto auto auto;
|
160
|
+
text-align: center;
|
161
|
+
width:70%;
|
162
|
+
}
|
163
|
+
|
164
|
+
#slide02 .text-container{
|
165
|
+
margin: 120px auto auto auto;
|
166
|
+
}
|
167
|
+
|
168
|
+
#slide02 .text-container > h2{
|
169
|
+
font-size: 2.8em;
|
170
|
+
margin-bottom: 0.6em;
|
171
|
+
}
|
172
|
+
|
173
|
+
#slide02 .text-container > p{
|
174
|
+
font-size: 1.4em;
|
175
|
+
line-height: 1.5em;
|
176
|
+
font-family: 'latoregular', sans-serif;
|
177
|
+
}
|
178
|
+
|
179
|
+
#slide03 .text-container > h3,
|
180
|
+
#slide04 .text-container > h3,
|
181
|
+
#slide05 .text-container > h3,
|
182
|
+
#slide06 .text-container > h3 {
|
183
|
+
font-size: 1.8em;
|
184
|
+
line-height: 1.5em;
|
185
|
+
font-family: 'latoregular', sans-serif;
|
186
|
+
}
|
187
|
+
|
188
|
+
#slide03 .text-container > p,
|
189
|
+
#slide04 .text-container > p,
|
190
|
+
#slide05 .text-container > p,
|
191
|
+
#slide06 .text-container > p {
|
192
|
+
font-size: 1.2em;
|
193
|
+
border: 1px solid #fff;
|
194
|
+
padding: 5px 3px;
|
195
|
+
margin: 5% auto;
|
196
|
+
}
|
197
|
+
|
198
|
+
#slide03 .text-container > img,
|
199
|
+
#slide04 .text-container > img,
|
200
|
+
#slide05 .text-container > img,
|
201
|
+
#slide06 .text-container > img {
|
202
|
+
width: 20%;
|
203
|
+
margin-bottom: 0;
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
#slide03 {
|
208
|
+
background: linear-gradient(rgba(119, 178, 82, 0.8), rgba(119, 178, 82, 0.8)),
|
209
|
+
url(images/bike-414278_1920.jpg);
|
210
|
+
}
|
211
|
+
|
212
|
+
#slide04 {
|
213
|
+
background:
|
214
|
+
linear-gradient(rgba(245, 166, 31, 0.8), rgba(245, 166, 31, 0.8)),
|
215
|
+
url(images/bike-414278_1920.jpg);
|
216
|
+
}
|
217
|
+
|
218
|
+
#slide05 {
|
219
|
+
background:
|
220
|
+
linear-gradient(rgba(22, 142, 149, 0.8), rgba(22, 142, 149, 0.8)),
|
221
|
+
url(images/bike-414278_1920.jpg);
|
222
|
+
}
|
223
|
+
|
224
|
+
#slide06 {
|
225
|
+
background:
|
226
|
+
linear-gradient(rgba(142, 119, 182, 0.8), rgba(142, 119, 182, 0.8)),
|
227
|
+
url(images/bike-414278_1920.jpg);
|
228
|
+
}
|
229
|
+
|
230
|
+
.slider-navi a,
|
231
|
+
.pagination a {
|
232
|
+
overflow: hidden;
|
233
|
+
}
|
234
|
+
|
235
|
+
.slider-navi a.disabled{
|
236
|
+
display: none;
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
.arrow {
|
241
|
+
z-index: 10;
|
242
|
+
cursor: pointer;
|
243
|
+
position: absolute;
|
244
|
+
top: 45%;
|
245
|
+
color: #FFF;
|
246
|
+
font-size: 1.2em;
|
247
|
+
}
|
248
|
+
|
249
|
+
.arrow i {
|
250
|
+
color: #D75254;
|
251
|
+
border: solid 1px #D75254;
|
252
|
+
padding: 7px;
|
253
|
+
}
|
254
|
+
|
255
|
+
.arrow i:hover{
|
256
|
+
border: solid 1px rgba(255, 255, 255, 0.7);
|
257
|
+
background: rgba(64, 64, 64, 0.5);
|
258
|
+
color: rgba(215,84,82,0.7);
|
259
|
+
}
|
260
|
+
|
261
|
+
.next {
|
262
|
+
position: absolute;
|
263
|
+
right: -70px;
|
264
|
+
}
|
265
|
+
|
266
|
+
.prev {
|
267
|
+
position: absolute;
|
268
|
+
left: -70px;
|
269
|
+
}
|
270
|
+
|
271
|
+
.pagination {
|
272
|
+
position: absolute;
|
273
|
+
bottom: 30px;
|
274
|
+
left: 45%;
|
275
|
+
width: 200px;
|
276
|
+
z-index: 30;
|
277
|
+
}
|
278
|
+
|
279
|
+
.pagination a {
|
280
|
+
float: left;
|
281
|
+
margin: 5px 5px 0;
|
282
|
+
width: 11px;
|
283
|
+
height: 11px;
|
284
|
+
border-radius: 5px;
|
285
|
+
background: rgba(238, 238, 238, 0.8);
|
286
|
+
vertical-align: middle;
|
287
|
+
}
|
288
|
+
|
289
|
+
.pagination a.active{
|
290
|
+
cursor: default;
|
291
|
+
background: rgba(215,84,82,1);
|
292
|
+
}
|
293
|
+
|
294
|
+
.pagination a.active:before{
|
295
|
+
margin-left: -130px;
|
296
|
+
}
|
63
297
|
```
|