質問編集履歴
3
追記 このパターンのドロップダウン は動きます。
title
CHANGED
File without changes
|
body
CHANGED
@@ -210,4 +210,20 @@
|
|
210
210
|
|
211
211
|
</div>
|
212
212
|
</div>
|
213
|
+
```
|
214
|
+
|
215
|
+
## 追記 このパターンのドロップダウン は動きます。
|
216
|
+
```ここに言語を入力
|
217
|
+
<div class="hoge-custom-select-wrap">
|
218
|
+
<div class="hoge-custom-select-main">
|
219
|
+
|
220
|
+
<select type="text" name="location" id="s">
|
221
|
+
<option value="">テスト</option>
|
222
|
+
<option value="">テスト</option>
|
223
|
+
<option value="">テスト</option>
|
224
|
+
<option value="">テスト</option>
|
225
|
+
</select>
|
226
|
+
|
227
|
+
</div>
|
228
|
+
</div>
|
213
229
|
```
|
2
追記 css と js を読み込むdivも入れたコードです。
title
CHANGED
File without changes
|
body
CHANGED
@@ -189,4 +189,25 @@
|
|
189
189
|
/***/ })
|
190
190
|
|
191
191
|
},[[11,"manifest","common"]]]);
|
192
|
+
```
|
193
|
+
|
194
|
+
## 追記 jsとcssは変更しない
|
195
|
+
|
196
|
+
他のドロップダウンでもこちらのjsとcssを使っているため、上記のjsとcssは変更しない方法で解決したいと考えています。
|
197
|
+
|
198
|
+
今回のはじめのプログラムのみ自動でリロードしてしまう状況です。
|
199
|
+
|
200
|
+
|
201
|
+
## 追記 css と js を読み込むdivも入れたコードです。
|
202
|
+
|
203
|
+
```ここに言語を入力
|
204
|
+
<div class="hoge-custom-select-wrap">
|
205
|
+
<div class="hoge-custom-select-main">
|
206
|
+
|
207
|
+
<select class = "yearlydropdown minimal" name="archive-dropdown" onclick ="document.location.href=this.options[this.selectedIndex].value;">
|
208
|
+
<?php wp_get_archives( array( 'type' => 'yearly', 'format' => 'option', 'post_type' => 'news', 'posts_per_page' => 5) ); ?>
|
209
|
+
</select>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
</div>
|
192
213
|
```
|
1
追加したCSS JSS を記載しました。 よろしくお願いいたします。
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,4 +18,175 @@
|
|
18
18
|
|
19
19
|
## やりたいこと
|
20
20
|
|
21
|
-
追加したcssやjsをそのままで、上記のプログラムを修正して、自動にリロードしないようにできないでしょうか。
|
21
|
+
追加したcssやjsをそのままで、上記のプログラムを修正して、自動にリロードしないようにできないでしょうか。
|
22
|
+
|
23
|
+
## 追記 CSS
|
24
|
+
|
25
|
+
```ここに言語を入力
|
26
|
+
.hoge-custom-select-wrap {
|
27
|
+
max-width: 152px;
|
28
|
+
width: 100%;
|
29
|
+
}
|
30
|
+
|
31
|
+
.hoge-custom-select-wrap * {
|
32
|
+
-webkit-box-sizing: border-box;
|
33
|
+
box-sizing: border-box;
|
34
|
+
margin: 0;
|
35
|
+
padding: 0;
|
36
|
+
}
|
37
|
+
|
38
|
+
.hoge-custom-select {
|
39
|
+
display: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
.hoge-custom-select-main {
|
43
|
+
display: -webkit-box;
|
44
|
+
display: -webkit-flex;
|
45
|
+
display: -ms-flexbox;
|
46
|
+
display: flex;
|
47
|
+
position: relative;
|
48
|
+
cursor: pointer;
|
49
|
+
}
|
50
|
+
|
51
|
+
@media screen and (min-width: 768px) {
|
52
|
+
.hoge-custom-select {
|
53
|
+
position: relative;
|
54
|
+
display: -webkit-box;
|
55
|
+
display: -webkit-flex;
|
56
|
+
display: -ms-flexbox;
|
57
|
+
display: flex;
|
58
|
+
cursor: pointer;
|
59
|
+
}
|
60
|
+
.hoge-custom-select-main {
|
61
|
+
display: none;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
.hoge-custom-select-main select {
|
66
|
+
text-align: left;
|
67
|
+
opacity: 1;
|
68
|
+
width: 100%;
|
69
|
+
max-height: 24px;
|
70
|
+
padding: 0 0 0 45px;
|
71
|
+
background-color: #fff;
|
72
|
+
color: #000;
|
73
|
+
border: 1px solid #000;
|
74
|
+
border-radius: 0;
|
75
|
+
font-size: 16px !important;
|
76
|
+
-moz-appearance: none;
|
77
|
+
appearance: none;
|
78
|
+
-webkit-appearance: none;
|
79
|
+
}
|
80
|
+
|
81
|
+
.hoge-custom-select__icon {
|
82
|
+
position: absolute;
|
83
|
+
right: 0;
|
84
|
+
top: 0;
|
85
|
+
width: 22px;
|
86
|
+
height: 100%;
|
87
|
+
background-color: #eee;
|
88
|
+
border: 1px solid #000;
|
89
|
+
}
|
90
|
+
|
91
|
+
.hoge-custom-select-main > .hoge-custom-select__icon {
|
92
|
+
pointer-events: none;
|
93
|
+
}
|
94
|
+
|
95
|
+
.hoge-custom-select__icon::after {
|
96
|
+
position: absolute;
|
97
|
+
right: 1px;
|
98
|
+
top: 50%;
|
99
|
+
-webkit-transform: translate(-2px, -50%);
|
100
|
+
transform: translate(-2px, -50%);
|
101
|
+
content: '';
|
102
|
+
width: 0;
|
103
|
+
height: 0;
|
104
|
+
padding: 0;
|
105
|
+
border-left: 6px solid transparent;
|
106
|
+
border-right: 6px solid transparent;
|
107
|
+
border-top: 8px solid #2e2e2e;
|
108
|
+
}
|
109
|
+
|
110
|
+
.hoge-custom-select__box {
|
111
|
+
position: relative;
|
112
|
+
width: 100%;
|
113
|
+
max-width: 130px;
|
114
|
+
text-align: center;
|
115
|
+
background-color: #fff;
|
116
|
+
}
|
117
|
+
|
118
|
+
.hoge-custom-select__item {
|
119
|
+
border: 1px solid #000;
|
120
|
+
border-right: 0;
|
121
|
+
height: 24px;
|
122
|
+
}
|
123
|
+
|
124
|
+
.hoge-custom-select__menu {
|
125
|
+
position: absolute;
|
126
|
+
top: 24px;
|
127
|
+
left: 0;
|
128
|
+
z-index: 10;
|
129
|
+
display: none;
|
130
|
+
width: 100%;
|
131
|
+
max-height: 145px;
|
132
|
+
overflow-y: scroll;
|
133
|
+
-ms-overflow-style: none;
|
134
|
+
scrollbar-width: none;
|
135
|
+
background-color: #fff;
|
136
|
+
border: 1px solid #ccc;
|
137
|
+
border-top: 0;
|
138
|
+
}
|
139
|
+
|
140
|
+
.hoge-custom-select__menu::-webkit-scrollbar {
|
141
|
+
display: none;
|
142
|
+
}
|
143
|
+
|
144
|
+
.hoge-custom-select__menu.active {
|
145
|
+
display: block;
|
146
|
+
}
|
147
|
+
|
148
|
+
.hoge-custom-select__menu-item {
|
149
|
+
padding: 4px 0;
|
150
|
+
}
|
151
|
+
|
152
|
+
.hoge-custom-select__menu-item.active {
|
153
|
+
background-color: #000;
|
154
|
+
color: #fff;
|
155
|
+
cursor: auto;
|
156
|
+
}
|
157
|
+
|
158
|
+
.hoge-custom-select__menu-item:not(:first-child):hover {
|
159
|
+
background-color: #eee;
|
160
|
+
}
|
161
|
+
|
162
|
+
/*# sourceMappingURL=scss-sourcemaps/global.css.map */
|
163
|
+
|
164
|
+
```
|
165
|
+
## 追記 js
|
166
|
+
```ここに言語を入力
|
167
|
+
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["global"],{
|
168
|
+
|
169
|
+
/***/ "./src/js/global.js":
|
170
|
+
/*!**************************!*\
|
171
|
+
!*** ./src/js/global.js ***!
|
172
|
+
**************************/
|
173
|
+
/*! no static exports found */
|
174
|
+
/***/ (function(module, exports, __webpack_require__) {
|
175
|
+
|
176
|
+
eval("/* WEBPACK VAR INJECTION */(function($) {function hogeCustomSelect(elem) {\n $(function () {\n var copySelect = function copySelect($select, $dest) {\n $select = $($select), $dest = $($dest);\n $dest.empty();\n $select.children('option').each(function () {\n $dest.append('<div class=\"hoge-custom-select__menu-item\" value=\"' + $(this).val() + '\">' + $(this).html() + '</div>');\n });\n };\n var bindActive = function bindActive($select, $dest, direction) {\n $select = $($select), $dest = $($dest);\n if (direction === '>') {\n var val = $select.val();\n $dest.children().removeClass('active');\n $dest.find('[value=\"' + val + '\"]').addClass('active');\n } else if (direction === '<') {\n var _val = $dest.children('.active').attr('value');\n $select.val(_val);\n }\n };\n var sortItems = function sortItems($dest) {\n $dest = $($dest);\n var $items = $dest.children();\n $dest.html($items.sort(function (a, b) {\n if ($(a).hasClass('active')) return -1;\n return parseInt($(a).attr('value')) - parseInt($(b).attr('value'));\n }));\n };\n var $wrap = $(elem);\n $wrap.each(function () {\n var $select = $(this).children('select');\n var $frame = $('<div class=\"hoge-custom-select\">\n <div class=\"hoge-custom-select__box\">\n <div class=\"hoge-custom-select__item js--toggle-menu-button\"></div>\n <div class=\"hoge-custom-select__menu\"></div>\n </div>\n <span class=\"hoge-custom-select__icon js--toggle-menu-button\"></span>\n </div>');\n var $menu = $frame.find('.hoge-custom-select__menu');\n $(this).after($frame);\n copySelect($(this).children('select'), $menu);\n $select.on('change', function () {\n bindActive($select, $menu, '>');\n sortItems($menu);\n $frame.find('.hoge-custom-select__item').empty().html($menu.find('.active').html());\n });\n var self = this;\n $menu.on('click', '>*', function () {\n var current_val = $menu.children('.active').attr('value');\n var val = $(this).attr('value');\n if (current_val !== val) {\n $menu.children().removeClass('active');\n $(this).addClass('active');\n sortItems($menu);\n bindActive($select, $menu, '<');\n $frame.find('.hoge-custom-select__item').empty().html($menu.find('.active').html());\n $select.trigger('change');\n }\n $menu.toggle(false);\n sortItems($menu);\n });\n $select.trigger('change');\n $frame.find('.js--toggle-menu-button').click(function () {\n $menu.toggle();\n });\n });\n });\n}\n\nhogeCustomSelect('.hoge-custom-select-main');\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\")))\n\n//# sourceURL=webpack:///./src/js/global.js?");
|
177
|
+
|
178
|
+
/***/ }),
|
179
|
+
|
180
|
+
/***/ 11:
|
181
|
+
/*!********************************!*\
|
182
|
+
!*** multi ./src/js/global.js ***!
|
183
|
+
********************************/
|
184
|
+
/*! no static exports found */
|
185
|
+
/***/ (function(module, exports, __webpack_require__) {
|
186
|
+
|
187
|
+
eval("module.exports = __webpack_require__(/*! ./src/js/global.js */\"./src/js/global.js\");\n\n\n//# sourceURL=webpack:///multi_./src/js/global.js?");
|
188
|
+
|
189
|
+
/***/ })
|
190
|
+
|
191
|
+
},[[11,"manifest","common"]]]);
|
192
|
+
```
|