<div class="wrapper">
<div class="title">
Custom Select Box
</div>
<div class="select_wrap">
<ul class="default_option">
<li>
<div class="option pizza">
<div class="icon"></div>
<p>Pizzas</p>
</div>
</li>
</ul>
<ul class="select_ul">
<li>
<div class="option pizza">
<div class="icon"></div>
<p>Pizzas</p>
</div>
</li>
<li>
<div class="option burger">
<div class="icon"></div>
<p>Burget</p>
</div>
</li>
<li>
<div class="option ice">
<div class="icon"></div>
<p>Ice Cream</p>
</div>
</li>
<li>
<div class="option fries">
<div class="icon"></div>
<p>Fried Potatoes</p>
</div>
</li>
</ul>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
font-family: 'Montserrat', sans-serif;
}
body{
background: #fdc75b;
color: #555555;
}
.wrapper{
position: absolute;
top: 35%;
left: 50%;
transform: translate(-50%,-50%);
}
.wrapper .title{
font-weight: 700;
font-size: 24px;
color: #fff;
}
.select_wrap{
width: 225px;
margin: 15px auto;
position: relative;
user-select: none;
}
.select_wrap .default_option{
background: #fff;
border-radius: 5px;
position: relative;
cursor: pointer;
}
.select_wrap .default_option li{
padding: 10px 20px;
}
.select_wrap .default_option:before{
content: "";
position: absolute;
top: 18px;
right: 18px;
width: 6px;
height: 6px;
border: 2px solid;
border-color: transparent transparent #555555 #555555;
transform: rotate(-45deg);
}
.select_wrap .select_ul{
position: absolute;
top: 55px;
left: 0;
width: 100%;
background: #fff;
border-radius: 5px;
display: none;
}
.select_wrap .select_ul li{
padding: 10px 20px;
cursor: pointer;
}
.select_wrap .select_ul li:first-child:hover{
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.select_wrap .select_ul li:last-child:hover{
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.select_wrap .select_ul li:hover{
background: #fff4dd;
}
.select_wrap .option{
display: flex;
align-items: center;
}
.select_wrap .option .icon{
background: url('https://i.imgur.com/oEZu0sK.png') no-repeat 0 0;
width: 32px;
height: 32px;
margin-right: 15px;
}
.select_wrap .option.pizza .icon{
background-position: 0 0;
}
.select_wrap .option.burger .icon{
background-position: 0 -35px;
}
.select_wrap .option.ice .icon{
background-position: 0 -72px;
}
.select_wrap .option.fries .icon{
background-position: 0 -111px;
width: 25px;
}
.select_wrap.active .select_ul{
display: block;
}
.select_wrap.active .default_option:before{
top: 25px;
transform: rotate(-225deg);
}
$(".default_option").click(function(){
$(this).parent().toggleClass("active");
})
$(".select_ul li").click(function(){
var currentele = $(this).html();
$(".default_option li").html(currentele);
$(this).parents(".select_wrap").removeClass("active");
})
This Pen doesn't use any external CSS resources.