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

回答編集履歴

1

コメントを受けて追記

2019/03/16 05:16

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37481

answer CHANGED
@@ -29,4 +29,85 @@
29
29
  bottom: 30px;
30
30
  cursor :pointer;
31
31
  }
32
+ ```
33
+
34
+ ##### コメントを受けて追記
35
+ ```html
36
+ <input type="checkbox" id="label1" />
37
+ <div class="box-wrap">
38
+ <div>テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト</div>
39
+ <div><img src="http://placehold.jp/500x600.png">
40
+ <!-- クリック時のみ表示する領域 -->
41
+ <div class="hidden_box">
42
+ <label for="label1"></label>
43
+ </div></div>
44
+ <!-- / .box-wrap --></div>
45
+
46
+ <!-- なんか </div> がひとつ余ってたので消しました。 -->
47
+
48
+ <div class="hidden_show">
49
+ <!--非表示要素ここから-->
50
+ <p>テスト文章ですテスト文章ですテスト文章ですテスト文章ですテスト文章です</p>
51
+ </div>
52
+ <!--ここまで-->
53
+ ```
54
+ ```css
55
+ .box-wrap {
56
+ position:relative;
57
+ max-width:1500px;
58
+ width: 100%;
59
+ text-align:center;
60
+ }
61
+ .box-wrap div {
62
+ display:inline-block;
63
+ width: 30%;
64
+ margin: 0;
65
+ padding:0;
66
+ text-align:left;
67
+ }
68
+
69
+ /* */
70
+
71
+ .hidden_box {
72
+ position:absolute;
73
+ right: 40px;
74
+ bottom: 30px;
75
+ cursor :pointer;
76
+ }
77
+
78
+ .hidden_box label {
79
+ width: 154px;
80
+ height: 29px;
81
+ background:url("http://placehold.jp/24/cc9999/993333/154x29.png") no-repeat center top;
82
+ display: block;
83
+ }
84
+
85
+ /*ボタンを切り替え*/
86
+ input:checked#label1 ~ .box-wrap label {
87
+ width: 154px;
88
+ height: 29px;
89
+ background:url("http://placehold.jp/24/000000/993333/154x29.png") no-repeat center top;
90
+ display: block;
91
+ }
92
+
93
+ /*チェックは見えなくする*/
94
+ input#label1 {
95
+ display: none;
96
+ }
97
+
98
+ /*中身を非表示にしておく*/
99
+ .hidden_show {
100
+ height: 0;
101
+ padding: 0;
102
+ overflow: hidden;
103
+ opacity: 0;
104
+ transition: 0.8s;
105
+ }
106
+
107
+ /*クリックで中身表示*/
108
+ input:checked#label1 ~ .hidden_show {
109
+ padding: 10px 0;
110
+ height: auto;
111
+ opacity: 1;
112
+ }
32
113
  ```