質問編集履歴

5

追記

2018/09/24 07:36

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -410,7 +410,7 @@
410
410
 
411
411
  ----------------------------追記----------------------------
412
412
 
413
- 以下のhtmlにすると一応やりたいことはできるようになったのですが、余分なselectボックが発生します。開発者ツールでは削除することは可能なのですがどこが該当しているのかが見つけられません。
413
+ **解決ソー**
414
414
 
415
415
  ```html
416
416
 
@@ -446,53 +446,45 @@
446
446
 
447
447
  <link rel="stylesheet" type="text/css" href="css/main.css">
448
448
 
449
+ </head>
450
+
451
+ <body>
452
+
453
+ <div class="center">
454
+
455
+ <div class="custom-select-wrapper">
456
+
457
+ <select name="sources" class="custom-select sources" id="sources" style="display: none;" placeholder="Source Type">
458
+
459
+ <option value="profile">Profile</option>
460
+
461
+ <option value="word">Word</option>
462
+
463
+ <option value="hashtag">Hashtag</option>
464
+
465
+ </select>
466
+
467
+ </div>
468
+
469
+ </div>
470
+
449
471
  <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
450
472
 
451
473
  <script type="text/javascript" src="js/main.js"></script>
452
474
 
475
+ </body>
476
+
453
- </head>
477
+ </html>
478
+
454
-
479
+ ```
480
+
481
+
482
+
455
- <body>
483
+ ```js
456
-
484
+
457
- <div class="center">
485
+ alert("test");
458
-
459
- <div class="custom-select-wrapper">
486
+
460
-
461
- <select name="sources" class="custom-select sources" id="sources" style="display: none;" placeholder="Source Type">
462
-
463
- <option value="profile">Profile</option>
464
-
465
- <option value="word">Word</option>
466
-
467
- <option value="hashtag">Hashtag</option>
468
-
469
- </select>
470
-
471
- <div class="custom-select sources">
472
-
473
- <span class="custom-select-trigger">Source Type</span>
474
-
475
- <div class="custom-options">
476
-
477
- <span class="custom-option undefined" data-value="profile">Profile</span>
478
-
479
- <span class="custom-option undefined" data-value="word">Word</span>
480
-
481
- <span class="custom-option undefined" data-value="hashtag">Hashtag</span>
482
-
483
- </div>
484
-
485
- </div>
486
-
487
- </div>
488
-
489
- </div>
490
-
491
- <script src="//static.codepen.io/assets/common/stopExecutionOnTimeout-41c52890748cd7143004e05d3c5f786c66b19939c4500ce446314d1748483e13.js"></script>
492
-
493
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
494
-
495
- <script>$(".custom-select").each(function () {
487
+ $(".custom-select").each(function () {
496
488
 
497
489
  var classes = $(this).attr("class"),
498
490
 
@@ -500,6 +492,8 @@
500
492
 
501
493
  name = $(this).attr("name");
502
494
 
495
+ alert("test");
496
+
503
497
  var template = '<div class="' + classes + '">';
504
498
 
505
499
  template += '<span class="custom-select-trigger">' + $(this).attr("placeholder") + '</span>';
@@ -514,8 +508,6 @@
514
508
 
515
509
  template += '</div></div>';
516
510
 
517
-
518
-
519
511
  $(this).wrap('<div class="custom-select-wrapper"></div>');
520
512
 
521
513
  $(this).hide();
@@ -564,10 +556,4 @@
564
556
 
565
557
  //# sourceURL=pen.js
566
558
 
567
- </script>
568
-
569
- </body>
570
-
571
- </html>
572
-
573
559
  ```

4

誤記

2018/09/24 07:36

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -410,7 +410,7 @@
410
410
 
411
411
  ----------------------------追記----------------------------
412
412
 
413
- 以下のhtmlにすると一応やりたいことはできるようになったのですが、余分なselectボックスが発生します。なぜ開発者ツールでは削除することは可能なのですがどこが該当しているのかが見つけられません。
413
+ 以下のhtmlにすると一応やりたいことはできるようになったのですが、余分なselectボックスが発生します。開発者ツールでは削除することは可能なのですがどこが該当しているのかが見つけられません。
414
414
 
415
415
  ```html
416
416
 

3

誤記

2018/09/24 01:50

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -408,7 +408,7 @@
408
408
 
409
409
 
410
410
 
411
- ----------------------------------------------------------------追記-------------------------------------------------------------------
411
+ ----------------------------追記----------------------------
412
412
 
413
413
  以下のhtmlにすると一応やりたいことはできるようになったのですが、余分なselectボックスが発生します。なぜ開発者ツールでは削除することは可能なのですがどこが該当しているのかが見つけられません。
414
414
 

2

追記

2018/09/24 01:49

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -405,3 +405,169 @@
405
405
  Edge
406
406
 
407
407
  jQuery3.3.1
408
+
409
+
410
+
411
+ ----------------------------------------------------------------追記-------------------------------------------------------------------
412
+
413
+ 以下のhtmlにすると一応やりたいことはできるようになったのですが、余分なselectボックスが発生します。なぜ開発者ツールでは削除することは可能なのですがどこが該当しているのかが見つけられません。
414
+
415
+ ```html
416
+
417
+ <!DOCTYPE html>
418
+
419
+ <html>
420
+
421
+ <head>
422
+
423
+ <meta charset="UTF-8">
424
+
425
+ <meta name="viewport" content="width=device-width, initial-scale=1">
426
+
427
+ <title>タイトル</title>
428
+
429
+ <meta name="description" content="ディスクリプション" />
430
+
431
+ <meta property="og:type" content="website" />
432
+
433
+ <meta property="og:title" content="タイトル" />
434
+
435
+ <meta property="og:image" content="/img/icon.png" />
436
+
437
+ <meta property="og:url" content="http://example.net/" />
438
+
439
+ <meta property="og:site_name" content="サイト名" />
440
+
441
+ <meta property="og:description" content="ディスクリプション" />
442
+
443
+ <meta name="robots" content="noarchive">
444
+
445
+ <link rel="shortcut icon" href="/img/favicon.ico">
446
+
447
+ <link rel="stylesheet" type="text/css" href="css/main.css">
448
+
449
+ <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
450
+
451
+ <script type="text/javascript" src="js/main.js"></script>
452
+
453
+ </head>
454
+
455
+ <body>
456
+
457
+ <div class="center">
458
+
459
+ <div class="custom-select-wrapper">
460
+
461
+ <select name="sources" class="custom-select sources" id="sources" style="display: none;" placeholder="Source Type">
462
+
463
+ <option value="profile">Profile</option>
464
+
465
+ <option value="word">Word</option>
466
+
467
+ <option value="hashtag">Hashtag</option>
468
+
469
+ </select>
470
+
471
+ <div class="custom-select sources">
472
+
473
+ <span class="custom-select-trigger">Source Type</span>
474
+
475
+ <div class="custom-options">
476
+
477
+ <span class="custom-option undefined" data-value="profile">Profile</span>
478
+
479
+ <span class="custom-option undefined" data-value="word">Word</span>
480
+
481
+ <span class="custom-option undefined" data-value="hashtag">Hashtag</span>
482
+
483
+ </div>
484
+
485
+ </div>
486
+
487
+ </div>
488
+
489
+ </div>
490
+
491
+ <script src="//static.codepen.io/assets/common/stopExecutionOnTimeout-41c52890748cd7143004e05d3c5f786c66b19939c4500ce446314d1748483e13.js"></script>
492
+
493
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
494
+
495
+ <script>$(".custom-select").each(function () {
496
+
497
+ var classes = $(this).attr("class"),
498
+
499
+ id = $(this).attr("id"),
500
+
501
+ name = $(this).attr("name");
502
+
503
+ var template = '<div class="' + classes + '">';
504
+
505
+ template += '<span class="custom-select-trigger">' + $(this).attr("placeholder") + '</span>';
506
+
507
+ template += '<div class="custom-options">';
508
+
509
+ $(this).find("option").each(function () {
510
+
511
+ template += '<span class="custom-option ' + $(this).attr("class") + '" data-value="' + $(this).attr("value") + '">' + $(this).html() + '</span>';
512
+
513
+ });
514
+
515
+ template += '</div></div>';
516
+
517
+
518
+
519
+ $(this).wrap('<div class="custom-select-wrapper"></div>');
520
+
521
+ $(this).hide();
522
+
523
+ $(this).after(template);
524
+
525
+ });
526
+
527
+ $(".custom-option:first-of-type").hover(function () {
528
+
529
+ $(this).parents(".custom-options").addClass("option-hover");
530
+
531
+ }, function () {
532
+
533
+ $(this).parents(".custom-options").removeClass("option-hover");
534
+
535
+ });
536
+
537
+ $(".custom-select-trigger").on("click", function () {
538
+
539
+ $('html').one('click', function () {
540
+
541
+ $(".custom-select").removeClass("opened");
542
+
543
+ });
544
+
545
+ $(this).parents(".custom-select").toggleClass("opened");
546
+
547
+ event.stopPropagation();
548
+
549
+ });
550
+
551
+ $(".custom-option").on("click", function () {
552
+
553
+ $(this).parents(".custom-select-wrapper").find("select").val($(this).data("value"));
554
+
555
+ $(this).parents(".custom-options").find(".custom-option").removeClass("selection");
556
+
557
+ $(this).addClass("selection");
558
+
559
+ $(this).parents(".custom-select").removeClass("opened");
560
+
561
+ $(this).parents(".custom-select").find(".custom-select-trigger").text($(this).text());
562
+
563
+ });
564
+
565
+ //# sourceURL=pen.js
566
+
567
+ </script>
568
+
569
+ </body>
570
+
571
+ </html>
572
+
573
+ ```

1

誤記

2018/09/24 01:48

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -68,284 +68,244 @@
68
68
 
69
69
  @import url(http://fonts.googleapis.com/earlyaccess/notosansjapanese.css);
70
70
 
71
+
72
+
71
73
  body {
72
74
 
75
+ background: #ededed;
76
+
73
- font-family: 'Noto Sans Japanese', serif;
77
+ font-family: 'Open Sans', sans-serif;
74
-
75
- overflow-y: auto;
76
-
77
- padding: 0px;
78
-
79
- margin: 0px;
80
78
 
81
79
  }
82
80
 
83
-
84
-
85
- h1 {
86
-
87
- padding: 5px;
88
-
89
- color: #010101;
90
-
91
- background: #eaf3ff;
92
-
93
- border-bottom: solid 3px #516ab6;
94
-
95
- margin: 0px;
81
+ .center {
96
-
82
+
97
- text-align: center;
83
+ position: absolute;
84
+
85
+ display: inline-block;
86
+
87
+ top: 50%; left: 50%;
88
+
89
+ transform: translate(-50%, -50%);
98
90
 
99
91
  }
100
92
 
101
93
 
102
94
 
95
+ /** Custom Select **/
96
+
103
- .makerStyle {
97
+ .custom-select-wrapper {
98
+
104
-
99
+ position: relative;
100
+
101
+ display: inline-block;
102
+
105
- margin-left: 5px;
103
+ user-select: none;
106
-
107
- }
108
-
109
-
110
-
111
-
112
-
113
- body {
114
-
115
- background: #ededed;
116
-
117
- font-family: 'Open Sans', sans-serif;
118
104
 
119
105
  }
120
106
 
107
+ .custom-select-wrapper select {
108
+
109
+ display: none;
110
+
111
+ }
112
+
121
- .center {
113
+ .custom-select {
114
+
122
-
115
+ position: relative;
116
+
117
+ display: inline-block;
118
+
119
+ }
120
+
121
+ .custom-select-trigger {
122
+
123
+ position: relative;
124
+
125
+ display: block;
126
+
127
+ width: 130px;
128
+
129
+ padding: 0 84px 0 22px;
130
+
131
+ font-size: 22px;
132
+
133
+ font-weight: 300;
134
+
135
+ color: #fff;
136
+
137
+ line-height: 60px;
138
+
139
+ background: #5c9cd8;
140
+
141
+ border-radius: 4px;
142
+
143
+ cursor: pointer;
144
+
145
+ }
146
+
147
+ .custom-select-trigger:after {
148
+
123
- position: absolute;
149
+ position: absolute;
124
-
150
+
125
- display: inline-block;
151
+ display: block;
152
+
126
-
153
+ content: '';
154
+
155
+ width: 10px; height: 10px;
156
+
127
- top: 50%; left: 50%;
157
+ top: 50%; right: 25px;
158
+
128
-
159
+ margin-top: -3px;
160
+
161
+ border-bottom: 1px solid #fff;
162
+
163
+ border-right: 1px solid #fff;
164
+
165
+ transform: rotate(45deg) translateY(-50%);
166
+
167
+ transition: all .4s ease-in-out;
168
+
169
+ transform-origin: 50% 0;
170
+
171
+ }
172
+
173
+ .custom-select.opened .custom-select-trigger:after {
174
+
175
+ margin-top: 3px;
176
+
177
+ transform: rotate(-135deg) translateY(-50%);
178
+
179
+ }
180
+
181
+ .custom-options {
182
+
183
+ position: absolute;
184
+
185
+ display: block;
186
+
187
+ top: 100%; left: 0; right: 0;
188
+
189
+ min-width: 100%;
190
+
191
+ margin: 15px 0;
192
+
193
+ border: 1px solid #b5b5b5;
194
+
195
+ border-radius: 4px;
196
+
197
+ box-sizing: border-box;
198
+
199
+ box-shadow: 0 2px 1px rgba(0,0,0,.07);
200
+
201
+ background: #fff;
202
+
203
+ transition: all .4s ease-in-out;
204
+
205
+
206
+
207
+ opacity: 0;
208
+
209
+ visibility: hidden;
210
+
211
+ pointer-events: none;
212
+
129
- transform: translate(-50%, -50%);
213
+ transform: translateY(-15px);
214
+
215
+ }
216
+
217
+ .custom-select.opened .custom-options {
218
+
219
+ opacity: 1;
220
+
221
+ visibility: visible;
222
+
223
+ pointer-events: all;
224
+
225
+ transform: translateY(0);
226
+
227
+ }
228
+
229
+ .custom-options:before {
230
+
231
+ position: absolute;
232
+
233
+ display: block;
234
+
235
+ content: '';
236
+
237
+ bottom: 100%; right: 25px;
238
+
239
+ width: 7px; height: 7px;
240
+
241
+ margin-bottom: -4px;
242
+
243
+ border-top: 1px solid #b5b5b5;
244
+
245
+ border-left: 1px solid #b5b5b5;
246
+
247
+ background: #fff;
248
+
249
+ transform: rotate(45deg);
250
+
251
+ transition: all .4s ease-in-out;
252
+
253
+ }
254
+
255
+ .option-hover:before {
256
+
257
+ background: #f9f9f9;
258
+
259
+ }
260
+
261
+ .custom-option {
262
+
263
+ position: relative;
264
+
265
+ display: block;
266
+
267
+ padding: 0 22px;
268
+
269
+ border-bottom: 1px solid #b5b5b5;
270
+
271
+ font-size: 18px;
272
+
273
+ font-weight: 600;
274
+
275
+ color: #b5b5b5;
276
+
277
+ line-height: 47px;
278
+
279
+ cursor: pointer;
280
+
281
+ transition: all .4s ease-in-out;
282
+
283
+ }
284
+
285
+ .custom-option:first-of-type {
286
+
287
+ border-radius: 4px 4px 0 0;
288
+
289
+ }
290
+
291
+ .custom-option:last-of-type {
292
+
293
+ border-bottom: 0;
294
+
295
+ border-radius: 0 0 4px 4px;
296
+
297
+ }
298
+
299
+ .custom-option:hover,
300
+
301
+ .custom-option.selection {
302
+
303
+ background: #f9f9f9;
304
+
305
+ }
130
306
 
131
307
  }
132
308
 
133
-
134
-
135
- /** Custom Select **/
136
-
137
- .custom-select-wrapper {
138
-
139
- position: relative;
140
-
141
- display: inline-block;
142
-
143
- user-select: none;
144
-
145
- }
146
-
147
- .custom-select-wrapper select {
148
-
149
- display: none;
150
-
151
- }
152
-
153
- .custom-select {
154
-
155
- position: relative;
156
-
157
- display: inline-block;
158
-
159
- }
160
-
161
- .custom-select-trigger {
162
-
163
- position: relative;
164
-
165
- display: block;
166
-
167
- width: 130px;
168
-
169
- padding: 0 84px 0 22px;
170
-
171
- font-size: 22px;
172
-
173
- font-weight: 300;
174
-
175
- color: #fff;
176
-
177
- line-height: 60px;
178
-
179
- background: #5c9cd8;
180
-
181
- border-radius: 4px;
182
-
183
- cursor: pointer;
184
-
185
- }
186
-
187
- .custom-select-trigger:after {
188
-
189
- position: absolute;
190
-
191
- display: block;
192
-
193
- content: '';
194
-
195
- width: 10px; height: 10px;
196
-
197
- top: 50%; right: 25px;
198
-
199
- margin-top: -3px;
200
-
201
- border-bottom: 1px solid #fff;
202
-
203
- border-right: 1px solid #fff;
204
-
205
- transform: rotate(45deg) translateY(-50%);
206
-
207
- transition: all .4s ease-in-out;
208
-
209
- transform-origin: 50% 0;
210
-
211
- }
212
-
213
- .custom-select.opened .custom-select-trigger:after {
214
-
215
- margin-top: 3px;
216
-
217
- transform: rotate(-135deg) translateY(-50%);
218
-
219
- }
220
-
221
- .custom-options {
222
-
223
- position: absolute;
224
-
225
- display: block;
226
-
227
- top: 100%; left: 0; right: 0;
228
-
229
- min-width: 100%;
230
-
231
- margin: 15px 0;
232
-
233
- border: 1px solid #b5b5b5;
234
-
235
- border-radius: 4px;
236
-
237
- box-sizing: border-box;
238
-
239
- box-shadow: 0 2px 1px rgba(0,0,0,.07);
240
-
241
- background: #fff;
242
-
243
- transition: all .4s ease-in-out;
244
-
245
-
246
-
247
- opacity: 0;
248
-
249
- visibility: hidden;
250
-
251
- pointer-events: none;
252
-
253
- transform: translateY(-15px);
254
-
255
- }
256
-
257
- .custom-select.opened .custom-options {
258
-
259
- opacity: 1;
260
-
261
- visibility: visible;
262
-
263
- pointer-events: all;
264
-
265
- transform: translateY(0);
266
-
267
- }
268
-
269
- .custom-options:before {
270
-
271
- position: absolute;
272
-
273
- display: block;
274
-
275
- content: '';
276
-
277
- bottom: 100%; right: 25px;
278
-
279
- width: 7px; height: 7px;
280
-
281
- margin-bottom: -4px;
282
-
283
- border-top: 1px solid #b5b5b5;
284
-
285
- border-left: 1px solid #b5b5b5;
286
-
287
- background: #fff;
288
-
289
- transform: rotate(45deg);
290
-
291
- transition: all .4s ease-in-out;
292
-
293
- }
294
-
295
- .option-hover:before {
296
-
297
- background: #f9f9f9;
298
-
299
- }
300
-
301
- .custom-option {
302
-
303
- position: relative;
304
-
305
- display: block;
306
-
307
- padding: 0 22px;
308
-
309
- border-bottom: 1px solid #b5b5b5;
310
-
311
- font-size: 18px;
312
-
313
- font-weight: 600;
314
-
315
- color: #b5b5b5;
316
-
317
- line-height: 47px;
318
-
319
- cursor: pointer;
320
-
321
- transition: all .4s ease-in-out;
322
-
323
- }
324
-
325
- .custom-option:first-of-type {
326
-
327
- border-radius: 4px 4px 0 0;
328
-
329
- }
330
-
331
- .custom-option:last-of-type {
332
-
333
- border-bottom: 0;
334
-
335
- border-radius: 0 0 4px 4px;
336
-
337
- }
338
-
339
- .custom-option:hover,
340
-
341
- .custom-option.selection {
342
-
343
- background: #f9f9f9;
344
-
345
- }
346
-
347
- }
348
-
349
309
  ```
350
310
 
351
311