You have the ability to create a custom select box and customize its appearance to your liking.
const sel = document.querySelector("#selected");
/* Define an array containing all the options */
const opt = [...document.querySelectorAll(".option")];
const inp = document.querySelector("#sel");
sel.addEventListener("click", () => {
const opts = document.querySelector("#options");
if (opts.classList.contains("open")) {
/* Hide the <ul> if it is visible */
opts.classList.remove("open");
} else {
/* Show the <ul> if it is hidden */
opts.classList.add("open");
}
});
opt.forEach((e, i, o) => {
/* Add an event listener for each option */
o[i].addEventListener("click", () => {
/* Store the selected option value in a variable */
const chosen = e.querySelector("span").innerHTML;
const opts = document.querySelector("#options");
/* Set the value of the selected option in the select box */
sel.innerHTML = chosen;
/* Set the value of the selected option in the hidden input field */
inp.value = chosen;
/* Close the <ul> */
opts.classList.remove("open");
});
})
.container {
display: flex;
}
#selected {
border: thin solid darkgray;
border-radius: 5px;
background: lightgray;
display: flex;
align-items: center;
cursor: pointer;
height: 1.5em;
margin-bottom: .2em;
padding-left: .5em;
min-width: 170px;
position: relative;
}
#selected:after {
font-family: FontAwesome;
content: "\f0d7";
margin-left: 1em;
position: absolute;
right: .5em;
}
#options {
display: none;
margin: 0;
padding: 0;
}
#options.open {
display: flex;
}
li {
display: flex;
justify-content: flex-start;
align-items: center;
cursor: pointer;
width: 60px;
}
li:hover {
background-color: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<form>
<input type="hidden" id="sel">
<div class="container">
<div id="selected">Choose Message Expiry</div>
<ul id="options">
<li class="option"><span>1 Day</span></li>
<li class="option"><span>2 Days</span></li>
<li class="option"><span>3 Days</span></li>
<li class="option"><span>4 Days</span></li>
</ul>
</div>
</form>