JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<h2>
This "custom" dropdown doesn't resize correctly.
</h2>
<div class="dropdown">
<select id="real_dropdown">
<option disabled="">Options</option>
<option value="long">Something super long in here</option>
<option value="short">Short</option>
</select>
</div>
<select id="width_tmp_select">
<option id="width_tmp_option"></option>
</select>
CSS
.dropdown {
width: 280px;
overflow: hidden;
background: url(https://secure.echobox.com/img/dropdown_arrow.png) no-repeat right transparent;
border: 1px solid black;
white-space: nowrap;
background-size: 18px 5px;
}
.dropdown select {
width: 100%;
background: transparent;
font-size: 16px;
border: 0;
border-radius: 0;
-webkit-appearance: none;
-moz-appearance: none;
font-family: "proxima-nova", Helvetica, Arial, sans-serif;
white-space: nowrap;
color: #56646E;
}
#width_tmp_select{
display : none;
}
JavaScript
$(document).ready(function() {
$('.dropdown').change(function(){
$("#width_tmp_option").html($('.dropdown option:selected').text());
$(this).width($("#width_tmp_select").width()+30);
});
});