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

質問編集履歴

1

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

2018/08/23 01:57

投稿

Satoshi.T
Satoshi.T

スコア8

title CHANGED
File without changes
body CHANGED
@@ -5,19 +5,86 @@
5
5
 
6
6
  記述したjsp
7
7
  ```jsp
8
+ <div class="check">
8
- <form:checkbox path="hogehoge" value="hoge" id="no1" />
9
+ <form:checkbox path="hogehoge" value="hoge" id="no1" />
9
- <label for="no1"><p>タグ1</p></label>
10
+ <label for="no1"><p>タグ1</p></label>
11
+ </div>
10
12
  ```
11
13
  開発者ツールで見ると、自分が記述したチェックボックスタグの下に
12
14
  ```html
15
+ <div class="check">
13
- <input id="no1" name="hogehoge" type="checkbox" value="hoge">
16
+ <input id="no1" name="hogehoge" type="checkbox" value="hoge">
14
- <input type="hidden" name="_hogehoge" value="on">
17
+ <input type="hidden" name="_hogehoge" value="on">
15
- <input type="hidden">
16
- <label for="no1"><p>タグ1</p></label>
18
+ <label for="no1"><p>タグ1</p></label>
19
+ </div>
17
20
  ```
18
21
 
19
- 謎のinputタグがつ作成されており、邪魔されているようです。
22
+ 謎のinputタグがつ作成されており、邪魔されているようです。
20
23
 
21
24
  ラジオボタンでは問題通り動いたので大丈夫かと思ったのですが、調べても原因がわかりません。
22
25
 
23
- 情報が不足しておりましたら随時追加させていただきますのでご助言お願いします。
26
+ 情報が不足しておりましたら随時追加させていただきますのでご助言お願いします。
27
+
28
+ ※適応したいCSS
29
+ ```CSS
30
+        .check {
31
+ width: 30%;
32
+ margin: 2em auto;
33
+ padding: 1em;
34
+ text-align: left;
35
+ border: 1px solid #cccccc;
36
+ }
37
+
38
+ .check input {
39
+ display: none;
40
+ }
41
+
42
+ .check label {
43
+ position: relative;
44
+ display: inline-block;
45
+ padding: 15px 0;
46
+ margin-right: 30px;
47
+ padding-right: 35px;
48
+ cursor: pointer;
49
+ }
50
+
51
+ .check input[type='checkbox'] {
52
+ position: absolute;
53
+ visibility: hidden !important;
54
+ }
55
+
56
+ .check input[type='checkbox']+label:before,
57
+ .check input[type='checkbox']+label:after {
58
+ position: absolute;
59
+ top: 41%;
60
+ -webkit-box-sizing: border-box;
61
+ box-sizing: border-box;
62
+ margin-top: -7.5px;
63
+ content: '';
64
+ }
65
+
66
+ .check input[type='checkbox']+label:before {
67
+ right: 0;
68
+ width: 30px;
69
+ height: 15px;
70
+ border: 1px solid #e4e3e1;
71
+ border-radius: 15px;
72
+ background: #ffffff;
73
+ }
74
+
75
+ .check input[type='checkbox']+label:after {
76
+ right: 15px;
77
+ width: 15px;
78
+ height: 15px;
79
+ -webkit-transition: all 200ms ease-out;
80
+ transition: all 200ms ease-out;
81
+ border-radius: 50%;
82
+ background: #bdbdbd;
83
+ }
84
+
85
+ .check input[type='checkbox']:checked+label:after {
86
+ right: 0;
87
+ background: #3c8dbc;
88
+ }
89
+
90
+ ```