質問編集履歴

2

fancybox html追加

2018/04/06 04:05

投稿

mimimi_chan
mimimi_chan

スコア12

test CHANGED
File without changes
test CHANGED
@@ -93,3 +93,219 @@
93
93
   }
94
94
 
95
95
  ```
96
+
97
+
98
+
99
+ ---
100
+
101
+ **以下使用したfancy boxコード**
102
+
103
+ ```html
104
+
105
+ <head>
106
+
107
+ <link href="css/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen">
108
+
109
+ <script type="text/javascript">
110
+
111
+ $(document).ready(function() {
112
+
113
+ /*
114
+
115
+ * Examples - images
116
+
117
+ */
118
+
119
+
120
+
121
+ $("a#example1").fancybox();
122
+
123
+
124
+
125
+ $("a#example2").fancybox({
126
+
127
+ 'overlayShow' : false,
128
+
129
+ 'transitionIn' : 'elastic',
130
+
131
+ 'transitionOut' : 'elastic'
132
+
133
+ });
134
+
135
+
136
+
137
+ $("a#example3").fancybox({
138
+
139
+ 'transitionIn' : 'none',
140
+
141
+ 'transitionOut' : 'none'
142
+
143
+ });
144
+
145
+
146
+
147
+ $("a#example4").fancybox({
148
+
149
+ 'opacity' : true,
150
+
151
+ 'overlayShow' : false,
152
+
153
+ 'transitionIn' : 'elastic',
154
+
155
+ 'transitionOut' : 'none'
156
+
157
+ });
158
+
159
+
160
+
161
+ $("a#example5").fancybox();
162
+
163
+
164
+
165
+ $("a#example6").fancybox({
166
+
167
+ 'titlePosition' : 'outside',
168
+
169
+ 'overlayColor' : '#000',
170
+
171
+ 'overlayOpacity' : 0.9
172
+
173
+ });
174
+
175
+
176
+
177
+ $("a#example7").fancybox({
178
+
179
+ 'titlePosition' : 'inside'
180
+
181
+ });
182
+
183
+
184
+
185
+ $("a#example8").fancybox({
186
+
187
+ 'titlePosition' : 'over'
188
+
189
+ });
190
+
191
+
192
+
193
+ $("a[rel=example_group]").fancybox({
194
+
195
+ 'transitionIn' : 'none',
196
+
197
+ 'transitionOut' : 'none',
198
+
199
+ 'titlePosition' : 'over',
200
+
201
+ 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
202
+
203
+ return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
204
+
205
+ }
206
+
207
+ });
208
+
209
+
210
+
211
+ /*
212
+
213
+ * Examples - various
214
+
215
+ */
216
+
217
+
218
+
219
+ $("#various1").fancybox({
220
+
221
+ 'titlePosition' : 'inside',
222
+
223
+ 'transitionIn' : 'none',
224
+
225
+ 'transitionOut' : 'none'
226
+
227
+ });
228
+
229
+
230
+
231
+ $("#various2").fancybox();
232
+
233
+
234
+
235
+ $("#various3").fancybox({
236
+
237
+ 'width' : '75%',
238
+
239
+ 'height' : '75%',
240
+
241
+ 'autoScale' : false,
242
+
243
+ 'transitionIn' : 'none',
244
+
245
+ 'transitionOut' : 'none',
246
+
247
+ 'type' : 'iframe'
248
+
249
+ });
250
+
251
+
252
+
253
+ $("#various4").fancybox({
254
+
255
+ 'padding' : 0,
256
+
257
+ 'autoScale' : false,
258
+
259
+ 'transitionIn' : 'none',
260
+
261
+ 'transitionOut' : 'none'
262
+
263
+ });
264
+
265
+ });
266
+
267
+ </script>
268
+
269
+
270
+
271
+
272
+
273
+ </head>
274
+
275
+
276
+
277
+ <body>
278
+
279
+ <div>
280
+
281
+ <a rel="example_group" href="image/big/1.jpg"><img alt="" src="image/small/1.jpg" /></a>
282
+
283
+ <a rel="example_group" href="image/big/2.jpg" title=""><img alt="" src="image/small/2.jpg" /></a>
284
+
285
+ <a rel="example_group" href="image/big/3.jpg" title=""><img alt="" src="image/small/3" /></a>
286
+
287
+ <a rel="example_group" href="image/big/4.jpg" title=""><img alt="" src="image/small/4.jpg" /></a>
288
+
289
+ </div>
290
+
291
+
292
+
293
+
294
+
295
+ <script type="text/javascript">
296
+
297
+
298
+
299
+ $(document).ready(function(){
300
+
301
+ $(".fancybox").fancybox();
302
+
303
+ });
304
+
305
+
306
+
307
+ </script>
308
+
309
+ </body>
310
+
311
+ ```

1

ご指摘ありがとうございます。参考リンクの修正、ランダムにする際に生じる問題点、使用したhtml css jsの追記をしました。

2018/04/06 04:05

投稿

mimimi_chan
mimimi_chan

スコア12

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ### 前提・実現したいこと
1
+ ### 実現したいこと
2
2
 
3
3
  複数のサムネイルをリロードするたびランダムに被らず表示させ、かつモーダルウィンドウを表示させたい。
4
4
 
@@ -14,10 +14,82 @@
14
14
 
15
15
  ### 試したこと
16
16
 
17
- ttp://favopict.blog15.fc2.com/blog-entry-16.html
17
+ [複数表示させるスクリプト](http://favopict.blog15.fc2.com/blog-entry-16.html)を参考にランダム表示にするよう指示してみたのですが、fancyboxと同時に作動させる方法がわかりませんでした。
18
18
 
19
- こちらを参考にしてみですが、fancyboxと同時に作動させる方法がわかりませんでした
19
+ また、画像が縦に並んでしまいます。参考サイトのよう横並びにしたです。
20
20
 
21
21
 
22
22
 
23
+
24
+
23
- ご回答よろくお願いいします。
25
+ **以下使用したランダムコード**
26
+
27
+ ```html
28
+
29
+ <div class="clip">
30
+
31
+ <script type="text/javascript">
32
+
33
+ <!--
34
+
35
+
36
+
37
+ var jumpURL = new Array();
38
+
39
+ var imgURL = new Array();
40
+
41
+ jumpURL[0] = "image/big/1.jpg";
42
+
43
+ jumpURL[1] = "image/big/2.jpg";
44
+
45
+ jumpURL[2] = "image/big/3.jpg";
46
+
47
+ jumpURL[3] = "image/big/4.jpg";
48
+
49
+
50
+
51
+ imgURL[0] = "image/small/1.jpg";
52
+
53
+ imgURL[1] = "image/small/2.jpg";
54
+
55
+ imgURL[2] = "image/small/3.jpg";
56
+
57
+ imgURL[3] = "image/small/4.jpg";
58
+
59
+
60
+
61
+ for(i = 0; i < 4; i++) {
62
+
63
+ var n = parseInt(Math.random() * jumpURL.length);
64
+
65
+ document.write('<div class="clip"><a href="'+jumpURL.slice(n,n+1)[0]+'" ><img src="'+imgURL.slice(n,n+1)[0]+'" border="0" width="125px"></a></div>');
66
+
67
+ jumpURL.splice(n,1);
68
+
69
+ imgURL.splice(n,1);
70
+
71
+ }
72
+
73
+
74
+
75
+ </script>
76
+
77
+ <br style="clear:both;">
78
+
79
+ ```
80
+
81
+ ```css
82
+
83
+ .clip{
84
+
85
+   float: left; /* 縦に並べる場合はこの部分を削除 */
86
+
87
+   margin: 0pt 20px 8px;
88
+
89
+   width: 80px;
90
+
91
+   height: 80px;
92
+
93
+  }
94
+
95
+ ```