<div class="custom-select">
<label for="combox">语言:</label>
<div class="combo-wrap">
<input type="text" class="combo__box" id="combox" />
<i class="arrow"></i>
<ul class="listbox">
<li>CSS</li>
<li>HTML</li>
<li>JavaScript</li>
<li>React</li>
<li>Vue</li>
</ul>
</div>
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
background-color: #291642;
font-family: "Gochi Hand", sans-serif;
color: #fff;
font-size: 130%;
letter-spacing: 0.1rem;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
min-height: 100vh;
}
// custom style for select
label {
padding: 5px;
font-size: 18px;
font-weight: 500;
display: block;
}
.combo-wrap {
display: inline-flex;
align-items: center;
position: relative;
}
.combo__box {
width: 30vw;
padding: 10px 35px 10px 5px;
border: 1px solid #fff;
box-sizing: border-box;
font-size: 14px;
background-color: #fff;
color: #212e59;
box-shadow: 0 0 5px #000;
}
.arrow {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 32px;
background-color: #212e59;
&::after {
content: "";
position: absolute;
top: calc(50% + 4px);
left: 50%;
transform: translate(-50%, -50%);
border: 6px solid #fff;
border-color: #fff transparent transparent;
}
}
.listbox {
display: none;
position: absolute;
list-style: none outside none;
z-index: 99;
max-height: 30vh;
overflow-y: auto;
background-color: #fff;
top: calc(100% + 0px);
left: 0;
right: 0;
box-shadow: 1px 2px 2px #000;
color: #333;
li {
background-color: #fff;
padding: 4px 6px;
&:hover {
background-color: #212e59;
color: #fff;
}
}
}
.combo-wrap:focus-within .listbox {
display: block;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.