質問編集履歴

1

効かないCSSコードの追加(全く同じ内容のラジオボタンはjspでも動作します)。もう一度確認したところ出力される謎のinputタグは1つだったので、修正。

2018/08/23 01:57

投稿

Satoshi.T
Satoshi.T

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,9 +12,13 @@
12
12
 
13
13
  ```jsp
14
14
 
15
- <form:checkbox path="hogehoge" value="hoge" id="no1" />
15
+ <div class="check">
16
16
 
17
+ <form:checkbox path="hogehoge" value="hoge" id="no1" />
18
+
17
- <label for="no1"><p>タグ1</p></label>
19
+ <label for="no1"><p>タグ1</p></label>
20
+
21
+ </div>
18
22
 
19
23
  ```
20
24
 
@@ -22,19 +26,21 @@
22
26
 
23
27
  ```html
24
28
 
25
- <input id="no1" name="hogehoge" type="checkbox" value="hoge">
29
+ <div class="check">
26
30
 
27
- <input type="hidden" name="_hogehoge" value="on">
31
+ <input id="no1" name="hogehoge" type="checkbox" value="hoge">
28
32
 
29
- <input type="hidden">
33
+ <input type="hidden" name="_hogehoge" value="on">
30
34
 
31
- <label for="no1"><p>タグ1</p></label>
35
+ <label for="no1"><p>タグ1</p></label>
36
+
37
+ </div>
32
38
 
33
39
  ```
34
40
 
35
41
 
36
42
 
37
- 謎のinputタグがつ作成されており、邪魔されているようです。
43
+ 謎のinputタグがつ作成されており、邪魔されているようです。
38
44
 
39
45
 
40
46
 
@@ -43,3 +49,131 @@
43
49
 
44
50
 
45
51
  情報が不足しておりましたら随時追加させていただきますのでご助言お願いします。
52
+
53
+
54
+
55
+ ※適応したいCSS
56
+
57
+ ```CSS
58
+
59
+        .check {
60
+
61
+ width: 30%;
62
+
63
+ margin: 2em auto;
64
+
65
+ padding: 1em;
66
+
67
+ text-align: left;
68
+
69
+ border: 1px solid #cccccc;
70
+
71
+ }
72
+
73
+
74
+
75
+ .check input {
76
+
77
+ display: none;
78
+
79
+ }
80
+
81
+
82
+
83
+ .check label {
84
+
85
+ position: relative;
86
+
87
+ display: inline-block;
88
+
89
+ padding: 15px 0;
90
+
91
+ margin-right: 30px;
92
+
93
+ padding-right: 35px;
94
+
95
+ cursor: pointer;
96
+
97
+ }
98
+
99
+
100
+
101
+ .check input[type='checkbox'] {
102
+
103
+ position: absolute;
104
+
105
+ visibility: hidden !important;
106
+
107
+ }
108
+
109
+
110
+
111
+ .check input[type='checkbox']+label:before,
112
+
113
+ .check input[type='checkbox']+label:after {
114
+
115
+ position: absolute;
116
+
117
+ top: 41%;
118
+
119
+ -webkit-box-sizing: border-box;
120
+
121
+ box-sizing: border-box;
122
+
123
+ margin-top: -7.5px;
124
+
125
+ content: '';
126
+
127
+ }
128
+
129
+
130
+
131
+ .check input[type='checkbox']+label:before {
132
+
133
+ right: 0;
134
+
135
+ width: 30px;
136
+
137
+ height: 15px;
138
+
139
+ border: 1px solid #e4e3e1;
140
+
141
+ border-radius: 15px;
142
+
143
+ background: #ffffff;
144
+
145
+ }
146
+
147
+
148
+
149
+ .check input[type='checkbox']+label:after {
150
+
151
+ right: 15px;
152
+
153
+ width: 15px;
154
+
155
+ height: 15px;
156
+
157
+ -webkit-transition: all 200ms ease-out;
158
+
159
+ transition: all 200ms ease-out;
160
+
161
+ border-radius: 50%;
162
+
163
+ background: #bdbdbd;
164
+
165
+ }
166
+
167
+
168
+
169
+ .check input[type='checkbox']:checked+label:after {
170
+
171
+ right: 0;
172
+
173
+ background: #3c8dbc;
174
+
175
+ }
176
+
177
+
178
+
179
+ ```