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

質問編集履歴

1

ご指摘のありました、内容を反映させました。

2018/05/12 09:30

投稿

kusaka00
kusaka00

スコア55

title CHANGED
File without changes
body CHANGED
@@ -10,6 +10,7 @@
10
10
  その後、B、Cと画像を入れ、Aの商品画像をクリックした後に他の商品画像をクリックすると
11
11
  画像がうまく切り替わりません。
12
12
 
13
+ ■HTML
13
14
  ```
14
15
  Aの商品画像
15
16
  <figure class="item_img">
@@ -34,8 +35,10 @@
34
35
  <img src="img/c_img01.jpg" alt="" class="ac_img">
35
36
  </span>
36
37
  </figure>
38
+ ```
37
39
 
38
- 自分で書いたJS
40
+ ■JS
41
+ ```
39
42
  <script>
40
43
  $(function(){
41
44
  var count = -1;
@@ -57,6 +60,30 @@
57
60
  });
58
61
  </script>
59
62
  ```
63
+ ■css
64
+ ```
65
+ .item_img .ac_img {
66
+ display: block;
67
+ }
68
+
69
+ .icon_switch span {
70
+ position: relative;
71
+ display: block;
72
+ }
73
+
74
+ .icon_switch figure span::after {
75
+ content: '';
76
+ display: inline-block;
77
+ width: calc( 70 / 340 * 100% );
78
+ padding-bottom: calc( 70 / 340 * 100% );
79
+ background-image: url(../img/ico_hads.png);
80
+ background-size: contain;
81
+ vertical-align: middle;
82
+ position: absolute;
83
+ bottom: 0;
84
+ right: 0;
85
+ }
86
+ ```
60
87
  原因は、最初にクリックした商品画像以外の商品画像をクリックしたときに
61
88
  countの値が0にならないせいだと思いますが、
62
89
  どうやったら0にできるかがわかりません。