combobox HTML
: https://codepen.io/gabep/pen/KXJoEK
CSS first their js
fist i UL style:
.like-select {
height:21px;
overflow:hidden;
width:8%;
}
.like-select li{
appearance: select;
color:red;
border-left: 1px solid blue;
border-right: 1px solid blue;
list-style-type: none;
}
make the first child your box:
.like-select li:first-child {
border: 1px solid blue;
}
make the last child element the bottom of the dropdown menu:
.like-select li:last-child {
border-bottom: 1px solid blue;
}
Assign a freezing effect to the list item:
.like-select li a:hover {
background-color: green !important;
}
.like-select li:first-child a:hover{
background-color: none !important;
}
a {
color:blue;
text-decoration:none;
width:100%;
}
now Js:
function load() {
// use querySelectorAll to search for specific elements of any type and list
var addfirst= document.querySelectorAll(".like-select li:first-child");
var ullist = document.querySelectorAll(".like-select");
ullist[0].innerHTML = addfirst[0].outerHTML + ullist[0].innerHTML ;
y = document.querySelectorAll(".like-select li");
y[0].onmouseenter = function(){
var comboboxwrapper = document.querySelectorAll(".like-select");
comboboxwrapper[0].style.height = "100px";
}
var i;
for (i = 1; i < y.length; i++) {
y[i].onmouseover = function(){
var selecteditem =document.querySelectorAll(".like-select li");
// change the value in the combo box with a value depending on
var mainitem = document.querySelectorAll(".like-select li:first-child");
mainitem[0].innerHTML = this.innerHTML;
};
} }
window.onload = load;
source
share