回答編集履歴

3

追記

2018/09/05 14:49

投稿

liveasnotes
liveasnotes

スコア1284

test CHANGED
@@ -205,3 +205,23 @@
205
205
  }
206
206
 
207
207
  ```
208
+
209
+
210
+
211
+ ---
212
+
213
+
214
+
215
+ 追記(20180905)
216
+
217
+ 完全ではないですが,それっぽいものが出来たので通知しときます(デモページも更新しました)
218
+
219
+ HTMLの手直しも簡素になりました
220
+
221
+ ![イメージ説明](23766abae18ee082d58f71dd84fe839b.gif)
222
+
223
+ border-radiusはオリジナルのままにしました.
224
+
225
+
226
+
227
+ 上下幅がずれる現象は,気が向いたら調べます

2

追記

2018/09/05 14:49

投稿

liveasnotes
liveasnotes

スコア1284

test CHANGED
@@ -101,3 +101,107 @@
101
101
  ![イメージ説明](d633d97ca81fbfab0b63f56ba0c80cc7.gif)
102
102
 
103
103
  こんな感じでしょうか?
104
+
105
+
106
+
107
+ ---
108
+
109
+
110
+
111
+ 追記
112
+
113
+ 書き忘れてましたが,`<input>`と`<label>`は離れてても良い(親子関係・兄弟関係は気にしなくて良い)みたいなので(__仕様を読んだわけではないので実務で使うなら要確認__),こういう入れ替えももちろんありです
114
+
115
+
116
+
117
+ あと,勝手に追加してる`dn`属性は属性セレクタでこういう指定をしています
118
+
119
+ ```css
120
+
121
+ [dn]{
122
+
123
+ display: none;
124
+
125
+ }
126
+
127
+ ```
128
+
129
+
130
+
131
+ ```html
132
+
133
+ <div class="input-group mb-3">
134
+
135
+ <label for="form_elm_1">
136
+
137
+ <!--略-->
138
+
139
+ </label>
140
+
141
+ <input type="checkbox" id="form_elm_1" dn><!--入れ替えた-->
142
+
143
+ <div class="form_elm_wrapper">
144
+
145
+ <!--略-->
146
+
147
+ </div>
148
+
149
+ </div>
150
+
151
+ ```
152
+
153
+ ```css
154
+
155
+ /* "~"(間接セレクタ)を"+"(隣接セレクタ)に書き換え */
156
+
157
+ input[id^="form_elm"]:checked +.form_elm_wrapper{
158
+
159
+ width: calc(100% - 2.6em);
160
+
161
+ }
162
+
163
+ ```
164
+
165
+
166
+
167
+ 意外と大したことはしてないですし,`height:auto;`や`width:auto;`にアニメーションが効かないところを考えると,見栄えを考慮するならもうひと工夫いるかもしれないですね
168
+
169
+ ```css
170
+
171
+ /*イメージ:wrapperの中にcontentsがある*/
172
+
173
+ #wrapper{
174
+
175
+ width: 0;
176
+
177
+ overflow: hidden;
178
+
179
+ transition: .5s .1s;/*!*/
180
+
181
+ }
182
+
183
+ #contents{
184
+
185
+ opacity: 0;
186
+
187
+ transition: .1s;/*!*/
188
+
189
+ }
190
+
191
+ #btn:checked +#wrapper{
192
+
193
+ width: 100px;
194
+
195
+ transition: .5s;
196
+
197
+ }
198
+
199
+ #btn:checked +#wrapper #contents{
200
+
201
+ opacity: 1;
202
+
203
+ transition: .1s .5s;
204
+
205
+ }
206
+
207
+ ```

1

追記

2018/09/04 08:14

投稿

liveasnotes
liveasnotes

スコア1284

test CHANGED
@@ -5,6 +5,10 @@
5
5
  [https://thimbleprojects.org/liveasnotes/537081/](https://thimbleprojects.org/liveasnotes/537081/)
6
6
 
7
7
  ![イメージ説明](98507eac60008771364c37c20e444c7e.gif)
8
+
9
+ (※上のデモは下のデモに書き換えられました/20180904)
10
+
11
+ ![イメージ説明](4b567f50cd16355490fef75c7e70877c.gif)
8
12
 
9
13
 
10
14
 
@@ -21,3 +25,79 @@
21
25
  [https://thimbleprojects.org/liveasnotes/536993/](https://thimbleprojects.org/liveasnotes/536993/)
22
26
 
23
27
  ![イメージ説明](f75cf78908e7e951c9626e7280cde194.gif)
28
+
29
+
30
+
31
+ ---
32
+
33
+
34
+
35
+ 書き加えて良いなら,
36
+
37
+ ```html
38
+
39
+ <!--書き加えた方-->
40
+
41
+ <div class="input-group mb-3">
42
+
43
+ <input type="checkbox" id="form_elm_1" dn>
44
+
45
+ <label for="form_elm_1">
46
+
47
+ <div class="input-group-prepend">
48
+
49
+ <span class="input-group-text" id="basic-addon1">@</span>
50
+
51
+ </div>
52
+
53
+ </label>
54
+
55
+ <div class="form_elm_wrapper">
56
+
57
+ <input type="text" class="form-control" placeholder="ユーザー名" aria-label="ユーザー名" aria-describedby="basic-addon1">
58
+
59
+ </div>
60
+
61
+ </div>
62
+
63
+
64
+
65
+ <!--書き加えてない方-->
66
+
67
+ <div class="input-group mb-3">
68
+
69
+ <div class="input-group-prepend">
70
+
71
+ <span class="input-group-text" id="basic-addon1">@</span>
72
+
73
+ </div>
74
+
75
+ <input type="text" class="form-control" placeholder="ユーザー名" aria-label="ユーザー名" aria-describedby="basic-addon1">
76
+
77
+ </div>
78
+
79
+ ```
80
+
81
+ ```css
82
+
83
+ .form_elm_wrapper{
84
+
85
+ width: 0;
86
+
87
+ overflow: hidden;
88
+
89
+ transition: .5s;
90
+
91
+ }
92
+
93
+ input[id^="form_elm"]:checked ~.form_elm_wrapper{
94
+
95
+ width: calc(100% - 2.6em);
96
+
97
+ }
98
+
99
+ ```
100
+
101
+ ![イメージ説明](d633d97ca81fbfab0b63f56ba0c80cc7.gif)
102
+
103
+ こんな感じでしょうか?