JSFiddle - React, Tailwind, and code Playground
HTML
<div class="custom-selectbox">
<div class="inner"><span>--</span></div>
<select name="month">
<option value="" selected="selected">--</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
</select>
</div>
<div class="custom-selectbox">
<div class="inner"><span>--</span></div>
<select name="month">
<option value="" selected="selected">--</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
</select>
</div>
CSS
.custom-selectbox {
position: relative;
}
.custom-selectbox select {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 240px;
height: 36px;
opacity: 0;
}
.custom-selectbox .inner {
position: relative;
z-index: 0;
box-sizing: border-box;
border: 1px solid #000;
padding: 0 12px;
width: 240px;
height: 36px;
font-size: 14px;
line-height: 36px;
}
.custom-selectbox .inner:before,
.custom-selectbox .inner:after {
content: '';
position: absolute;
display: block;
}
.custom-selectbox .inner:before {
top: 0;
right: 0;
bottom: 0;
width: 24px;
background: #000;
}
.custom-selectbox .inner:after {
top: 50%;
right: 7px;
margin-top: -3px;
width: 0;
height: 0;
border: solid transparent;
border-top-color: #fff;
border-width: 5px 5px 0 5px;
}
JavaScript
function change_selectbox(select) {
var item = select.children('option:selected').text();
select.prev('.inner').find('span').text(item);
}
jQuery(function(){
// セレクトボックスの変更時に.innerのspanを書き換え
jQuery('select').change(function() {
change_selectbox(jQuery(this));
});
});