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

質問編集履歴

3

コードの掲載

2019/08/28 07:20

投稿

GenkiSugiyama
GenkiSugiyama

スコア86

title CHANGED
File without changes
body CHANGED
@@ -9,4 +9,220 @@
9
9
 
10
10
  ユーザーには常に1枚目の状態で画像を表示させたいのですが、画像2枚目のような表示を防ぐ方法があればご教示いただけますと幸いです。
11
11
 
12
- よろしくお願いいたします。
12
+ よろしくお願いいたします。
13
+
14
+ **追記**
15
+
16
+ コードの提示をご依頼いただいたので記述いたします。
17
+
18
+ ```HTML
19
+ <div class="main-visual">
20
+ <div class="add-wrapper">
21
+ <div class="swiper-container swiper1">
22
+ <div class="swiper-wrapper">
23
+ <div class="swiper-slide slide1">
24
+ <a href="<?php echo MODULE_WEB_ROOT; ?>findinfo" class="cover"></a>
25
+ </div>
26
+ <div class="swiper-slide slide2">
27
+ <a href="<?php echo MODULE_WEB_ROOT; ?>findinfo" class="cover"></a>
28
+ </div>
29
+ <div class="swiper-slide slide3">
30
+ <a href="<?php echo MODULE_WEB_ROOT; ?>findinfo" class="cover"></a>
31
+ </div>
32
+ <div class="swiper-slide slide4">
33
+ <a href="<?php echo MODULE_WEB_ROOT; ?>findinfo" class="cover"></a>
34
+ </div>
35
+ <div class="swiper-slide slide5">
36
+ <a href="<?php echo MODULE_WEB_ROOT; ?>findinfo" class="cover"></a>
37
+ </div>
38
+ </div>
39
+ <!-- swiperのページネーション -->
40
+ <div class="swiper-pagination page1"></div>
41
+ <!-- ナビゲーション -->
42
+ <div class="swiper-button-prev prev1"></div>
43
+ <div class="swiper-button-next next1"></div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ ```
48
+
49
+ ```CSS
50
+ .main-visual {
51
+ width: 100%;
52
+ height: 522px;
53
+ background-image: url(../background-image);
54
+ background-repeat: repeat;
55
+ z-index: 0;
56
+ background-color: #F0F0F0;
57
+ overflow-x: hidden;
58
+ overflow-y: hidden;
59
+ position: relative;
60
+ }
61
+
62
+ .add-wrapper {
63
+ margin-left: auto;
64
+ margin-right: auto;
65
+ max-width: 900px;
66
+ }
67
+
68
+ .swiper1 {
69
+ width: 100%;
70
+ overflow: visible;
71
+ z-index: 1;
72
+ height: 520px;
73
+ }
74
+
75
+ .swiper1 .swiper-slide {
76
+ vertical-align: middle;
77
+ margin-top: 88px;
78
+ position: relative;
79
+ transition: all .7s cubic-bezier(0.165, 0.84, 0.44, 1) 0s;
80
+ height: 335px !important;
81
+ }
82
+
83
+ .swiper1 .swiper-slide .mv-img {
84
+ width: 670px !important;
85
+ height: 335px !important;
86
+ }
87
+
88
+ .swiper1 .swiper-slide-active {
89
+ height: 450px !important;
90
+ width: 900px !important;
91
+ margin-top: 30px;
92
+ }
93
+
94
+ .swiper1 .swiper-slide-active .mv-img {
95
+ height: 450px !important;
96
+ width: 900px !important;
97
+ }
98
+
99
+ .swiper1 .swiper-slide-prev,
100
+ .swiper1 .swiper-slide-next {
101
+ width: 100% !important;
102
+ height: 335px !important;
103
+ }
104
+
105
+ .swiper1 .swiper-slide-prev::after,
106
+ .swiper1 .swiper-slide-next::after {
107
+ content: "";
108
+ position: absolute;
109
+ display: block;
110
+ top: 0;
111
+ left: 0;
112
+ width: 100%;
113
+ height: 100%;
114
+ background: rgba(0, 0, 0, 0.7);
115
+ }
116
+
117
+ .swiper1 .swiper-slide-prev .mv-img {
118
+ width: 670px !important;
119
+ height: 335px !important;
120
+ position: absolute;
121
+ top: 0;
122
+ right: 0;
123
+ }
124
+
125
+ .swiper1 .swiper-slide-next .mv-img {
126
+ width: 670px !important;
127
+ height: 335px !important;
128
+ position: absolute;
129
+ top: 0;
130
+ left: 0;
131
+ }
132
+
133
+ .swiper1 .swiper-pagination {
134
+ width: 100%;
135
+ left: 0;
136
+ bottom: 10px;
137
+ }
138
+
139
+ .swiper1 .swiper-button-next,
140
+ .swiper1 .swiper-button-prev {
141
+ transform: translateY(-50%) translateX(-50%);
142
+ -webkit-transform: translateY(-50%) translateX(-50%);
143
+ margin-top: 0;
144
+ }
145
+
146
+ .swiper1 .swiper-button-next{
147
+ right: calc(-50vw + 470px);
148
+ width: 32px;
149
+ height: 60px;
150
+ background-image: url(../swiper-button-image);
151
+ }
152
+
153
+ .swiper1 .swiper-button-prev{
154
+ left: calc(-50vw + 496px);
155
+ width: 32px;
156
+ height: 60px;
157
+ background-image: url(../swiper-button-image);
158
+ }
159
+
160
+ .swiper-pagination-bullet-active {
161
+ opacity: 1;
162
+ background: #91d539;
163
+ }
164
+
165
+ .swiper1 .slide1 {
166
+ background-image: url(../slide-image);
167
+ background-position: center;
168
+ background-size: cover;
169
+ background-repeat: no-repeat;
170
+ }
171
+ .swiper1 .slide2 {
172
+ background-image: url(../slide-image);
173
+ background-position: center;
174
+ background-size: cover;
175
+ background-repeat: no-repeat;
176
+ }
177
+ .swiper1 .slide3 {
178
+ background-image: url(../slide-image);
179
+ background-position: center;
180
+ background-size: cover;
181
+ background-repeat: no-repeat;
182
+ }
183
+ .swiper1 .slide4 {
184
+ background-image: url(../slide-image);
185
+ background-position: center;
186
+ background-size: cover;
187
+ background-repeat: no-repeat;
188
+ }
189
+ .swiper1 .slide5 {
190
+ background-image: url(../slide-image);
191
+ background-position: center;
192
+ background-size: cover;
193
+ background-repeat: no-repeat;
194
+ }
195
+
196
+ ```
197
+
198
+ ```JavaScript
199
+ window.addEventListener('load', function() {
200
+ var mySwiper = new Swiper ('.swiper1', {
201
+ loop: true,
202
+ slidesPerView: '1',
203
+ centeredSlides : true,
204
+ loopedSlides:5,
205
+ spaceBetween: 0,
206
+ clickable: true,
207
+ breakpoints: {
208
+ 960: {
209
+ slidesPerView: 1,
210
+ spaceBetween: 0
211
+ }
212
+ },
213
+ navigation: {
214
+ nextEl: '.next1',
215
+ prevEl: '.prev1',
216
+ },
217
+ pagination: {
218
+ el: '.page1',
219
+ },
220
+ autoplay: {
221
+ delay: 7000,
222
+ disableOnInteraction: false
223
+ },
224
+ speed: 700,
225
+ roundLengths: true,
226
+ });
227
+ }, false);
228
+ ```

2

画像の差し替え

2019/08/28 07:20

投稿

GenkiSugiyama
GenkiSugiyama

スコア86

title CHANGED
File without changes
body CHANGED
@@ -2,10 +2,10 @@
2
2
  Swiper.jsを利用しサイトのメインビジュアル部分をスライドさせようとしています。
3
3
 
4
4
  最終的な表示は下記のスクリーンショットです。↓
5
- ![![イメージ説明](a09b4dfa3c475acadb310aec8b1dc8bb.png)](4b6094882e7a9c65a66cdf0ab94c0010.png)
5
+ ![イメージ説明](50bc7d747d1d5a4fe87ae432e3543e3d.png)
6
6
 
7
7
  ただ、ページをロードすると、読み込み途中にCSS適用前の画像が横並びに表示されてしまいます。↓
8
- ![イメージ説明](da19df54c87d9306f5987ec572fd6b5f.png)
8
+ ![イメージ説明](cdc2d95624d2b3fe05367bc4d0946121.png)
9
9
 
10
10
  ユーザーには常に1枚目の状態で画像を表示させたいのですが、画像2枚目のような表示を防ぐ方法があればご教示いただけますと幸いです。
11
11
 

1

文言修正

2019/08/28 06:59

投稿

GenkiSugiyama
GenkiSugiyama

スコア86

title CHANGED
File without changes
body CHANGED
@@ -7,6 +7,6 @@
7
7
  ただ、ページをロードすると、読み込み途中にCSS適用前の画像が横並びに表示されてしまいます。↓
8
8
  ![イメージ説明](da19df54c87d9306f5987ec572fd6b5f.png)
9
9
 
10
- ユーザーにはCSSが適用されたタイミングで画像を表示させたいのですが、画像2枚目のような表示を防ぐ方法があればご教示いただけますと幸いです。
10
+ ユーザーには常に1枚目の状態で画像を表示させたいのですが、画像2枚目のような表示を防ぐ方法があればご教示いただけますと幸いです。
11
11
 
12
12
  よろしくお願いいたします。