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

質問編集履歴

1

2018/02/11 09:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,136 +1,3 @@
1
- ### 前提・実現したいこと
2
- 投稿された画像を(eachされた)スライドショーで表示させたい
3
- https://bkosborne.com/jquery-waterwheel-carouselを参考にコードをダウンロードしてきて
4
- 画像部分をアレンジして作成しました。
5
-
6
- ### 発生している問題・エラーメッセージ
7
-
8
- ```
9
-  画像が表示されません。
10
-  しかし検証してみると小さく表示があるのですが透明であるのかがわかりません。
11
- ```
12
-
13
- ![イメージ説明](2d212b63cec083ece4efcccb90331162.png)
14
-
15
- ![イメージ説明](0ea6dde98437f42d3b2e8609263c54ee.png)
16
-
17
- ### 該当のソースコード
18
-
19
- ```HTML
20
- <h1>Carousel Demo</h1>
21
- <div id="carousel">
22
- <% @products.each do |product| %>
23
- !!! この部分でID名を取得しています。!!!
24
- <script type="text/javascript">
25
- $(function(){
26
- $('img').each(function(i){
27
- $(this).attr('id','item-' + (i+1) );
28
- });
29
- });
30
- </script>
31
-
32
- <a href="#"><%= attachment_image_tag product, :image %></a>
33
- <% end %>
34
- </div>
35
- <a href="#" id="prev">Prev</a> | <a href="#" id="next">Next</a>
36
-
37
-
38
- ```
39
-
40
-
41
- ```CSS
42
- body {
43
- font-family:Arial;
44
- font-size:12px;
45
- background:#ededed;
46
- }
47
- .example-desc {
48
- margin:3px 0;
49
- padding:5px;
50
- }
51
-
52
- #carousel {
53
- width:960px;
54
- border:1px solid #222;
55
- height:300px;
56
- position:relative;
57
- clear:both;
58
- overflow:hidden;
59
- background:#FFF;
60
- }
61
- #carousel img {
62
- visibility:hidden; /* hide images until carousel can handle them */
63
- cursor:pointer; /* otherwise it's not as obvious items can be clicked */
64
- }
65
-
66
- .split-left {
67
- width:450px;
68
- float:left;
69
- }
70
- .split-right {
71
- width:400px;
72
- float:left;
73
- margin-left:10px;
74
- }
75
- #callback-output {
76
- height:250px;
77
- overflow:scroll;
78
- }
79
- textarea#newoptions {
80
- width:430px;
81
- }
82
- ```
83
-
84
- ```javascript
85
-
86
- <script type="text/javascript">
87
- $(document).ready(function () {
88
- var carousel = $("#carousel").waterwheelCarousel({
89
- flankingItems: 3,
90
- movingToCenter: function ($item) {
91
- $('#callback-output').prepend('movingToCenter: ' + $item.attr('id') + '<br/>');
92
- },
93
- movedToCenter: function ($item) {
94
- $('#callback-output').prepend('movedToCenter: ' + $item.attr('id') + '<br/>');
95
- },
96
- movingFromCenter: function ($item) {
97
- $('#callback-output').prepend('movingFromCenter: ' + $item.attr('id') + '<br/>');
98
- },
99
- movedFromCenter: function ($item) {
100
- $('#callback-output').prepend('movedFromCenter: ' + $item.attr('id') + '<br/>');
101
- },
102
- clickedCenter: function ($item) {
103
- $('#callback-output').prepend('clickedCenter: ' + $item.attr('id') + '<br/>');
104
- }
105
- });
106
-
107
- $('#prev').bind('click', function () {
108
- carousel.prev();
109
- return false
110
- });
111
-
112
- $('#next').bind('click', function () {
113
- carousel.next();
114
- return false;
115
- });
116
-
117
- $('#reload').bind('click', function () {
118
- newOptions = eval("(" + $('#newoptions').val() + ")");
119
- carousel.reload(newOptions);
120
- return false;
121
- });
122
-
123
- });
124
- </script>
125
- ```
126
-
127
- ```
128
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
129
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
130
- <script type="text/javascript" src="/jquery.waterwheelCarousel.min.js"></script>
131
- <script type="text/javascript" src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
132
- <script type="text/javascript" src="js/jquery.waterwheelCarousel.js"></script>
133
- ```
134
1
  ### 試したこと
135
2
  http://code.jquery.com/jquery-1.9.1.min.js
136
3