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

質問編集履歴

3

再度ソース追加

2021/12/15 01:27

投稿

com.woody
com.woody

スコア43

title CHANGED
File without changes
body CHANGED
@@ -9,6 +9,19 @@
9
9
  レイアウトが崩れないように(真上にある年月のテキストフィールドと同じ幅になるように)コメントのdiv-formが生きるような修正方法をご教示いただきたいです。
10
10
 
11
11
  ```html
12
+ <script
13
+ src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"
14
+ integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
15
+ crossorigin="anonymous"
16
+ ></script>
17
+ <script
18
+ src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
19
+ integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8="
20
+ crossorigin="anonymous"
21
+ ></script>
22
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap-validator@0.11.9/js/validator.min.js"></script>
23
+ ```
24
+ ```html
12
25
  <form class="form-horizontal" method="post" id="postform" onsubmit="return false;">
13
26
  <div class="panel panel-info">
14
27
  <div class="panel-body">
@@ -74,4 +87,62 @@
74
87
  } else {
75
88
  $("#day").attr("required", false);
76
89
  }
90
+ ```
91
+ ```css
92
+
93
+ input[type="checkbox"] {
94
+ display: none;
95
+ }
96
+
97
+ input[type="checkbox"] + label.check {
98
+ position: relative;
99
+ cursor: pointer;
100
+ display: inline-block;
101
+ width: 70px;
102
+ height: 28px;
103
+ color: #969696;
104
+ border: 1px solid #a3a3a3;
105
+ border-radius: 3px;
106
+ background-color: #ffffff;
107
+ margin-top: 7px;
108
+ }
109
+
110
+ input[type="checkbox"]:checked + label.check {
111
+ border: 1px solid #4db4e4;
112
+ background-color: #4db4e4;
113
+ }
114
+
115
+ input[type="checkbox"] + label.check::before {
116
+ content: "固定日";
117
+ position: absolute;
118
+ top: 4px;
119
+ left: auto;
120
+ right: 6px;
121
+ }
122
+
123
+ input[type="checkbox"]:checked + label.check::before {
124
+ content: "営業日";
125
+ position: absolute;
126
+ left: 6px;
127
+ right: auto;
128
+ color: #ffffff;
129
+ }
130
+
131
+ input[type="checkbox"] + label.check > div {
132
+ position: absolute;
133
+ top: 2px;
134
+ left: 2px;
135
+ width: 12px;
136
+ height: 22px;
137
+ border: 1px solid #a3a3a3;
138
+ border-radius: 3px;
139
+ background-color: #ffffff;
140
+ transition: 0.2s;
141
+ }
142
+
143
+ input[type="checkbox"]:checked + label.check > div {
144
+ border: 1px solid transparent;
145
+ left: 54px;
146
+ }
147
+
77
148
  ```

2

ソースを追加しました

2021/12/15 01:27

投稿

com.woody
com.woody

スコア43

title CHANGED
File without changes
body CHANGED
@@ -30,10 +30,10 @@
30
30
  <div class="form-group">
31
31
  <label class="col-sm-2 col-xs-3 control-label" for="year_month">年月</label>
32
32
  <div class="col-sm-2 col-xs-4">
33
- <input class="form-control" type="text" name="year" />
33
+ <input class="form-control" type="text" name="year" required />
34
34
  </div>
35
35
  <div class="col-sm-2 col-xs-3">
36
- <input class="form-control" type="text" name="month" />
36
+ <input class="form-control" type="text" name="month" required />
37
37
  </div>
38
38
  </div>
39
39
 

1

ソースを追加しました

2021/12/14 14:34

投稿

com.woody
com.woody

スコア43

title CHANGED
File without changes
body CHANGED
@@ -6,10 +6,28 @@
6
6
  ところがこの行を有効にすると、レイアウトが崩れてしまいます。
7
7
  ![イメージ説明](964054ce83cc8f4d957cdf5f1c3e617e.png)
8
8
 
9
- レイアウトが崩れないようにコメントのdiv-formが生きるような修正方法をご教示いただきたいです。
9
+ レイアウトが崩れないように(真上にある年月のテキストフィールドと同じ幅になるように)コメントのdiv-formが生きるような修正方法をご教示いただきたいです。
10
10
 
11
11
  ```html
12
+ <form class="form-horizontal" method="post" id="postform" onsubmit="return false;">
13
+ <div class="panel panel-info">
14
+ <div class="panel-body">
12
15
  <div class="form-group">
16
+ <label class="col-sm-2 col-xs-3 control-label" for="notify">通知方法</label>
17
+ <div class="col-sm-4 col-xs-9">
18
+ <select
19
+ class="form-control input-lg"
20
+ id="notify"
21
+ name="notify"
22
+ onchange="notifyChange()"
23
+ >
24
+ <option value="メール">メール</option>
25
+ <option value="タスク" selected>タスク</option>
26
+ </select>
27
+ </div>
28
+ </div>
29
+
30
+ <div class="form-group">
13
31
  <label class="col-sm-2 col-xs-3 control-label" for="year_month">年月</label>
14
32
  <div class="col-sm-2 col-xs-4">
15
33
  <input class="form-control" type="text" name="year" />
@@ -36,4 +54,24 @@
36
54
  <label class="check" for="elapsed"><div></div></label>
37
55
  </div>
38
56
  </div>
57
+ </div>
58
+ <div class="panel panel-plain">
59
+ <div class="panel-heading">
60
+ <div class="pull-right col-sm-3">
61
+ <button type="submit" class="btn btn-success btn-long pull-right" id="send_button">
62
+ <em class="fas fas-fw fa-check-circle">&nbsp;</em>登録
63
+ </button>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </form>
69
+ ```
70
+ ```javascript
71
+ function notifyChange() {
72
+ if ($("#notify").val() == "タスク") {
73
+ $("#day").attr("required", true);
74
+ } else {
75
+ $("#day").attr("required", false);
76
+ }
39
77
  ```