<select>
<option value="first">First option</option>
<option value="second">Second option</option>
<option value="third">Third option</option>
</select>
select {
appearance: none;
@supports (appearance: base-select) {
&,
&::picker(select) {
appearance: base-select;
}
}
}
select {
display: flex;
justify-content: space-between;
min-width: 300px;
align-items: center;
color: white;
padding-block: 10px;
padding-inline: 10px 30px;
border-radius: 5px;
border: 2px solid plum;
cursor: pointer;
font-weight: 700;
background: hotpink
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23FFF' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E%0A")
right 10px center / 20px no-repeat;
@supports (appearance: base-select) {
padding-inline: 10px;
background-image: none;
&::picker-icon {
content: "";
width: 20px;
height: 20px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23FFF' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E%0A");
transition: rotate 0.2s ease-out;
}
&:open::picker-icon {
rotate: 180deg;
}
&::picker(select) {
padding: 0;
margin-top: 5px;
border: 2px solid hotpink;
background: white;
border-radius: 5px;
font-weight: 400;
opacity: 0;
height: 0;
overflow: clip;
transition: height 0.5s ease-out, opacity 0.5s ease-out, overlay 0.5s,
display 0.5s;
transition-behavior: allow-discrete;
}
&:open::picker(select) {
opacity: 1;
height: calc-size(auto, size);
overflow: auto;
@starting-style {
opacity: 0;
height: 0;
}
}
option {
padding: 10px;
border-top: 1px solid plum;
cursor: pointer;
transition-property: color, background;
transition-duration: 0.2s;
transition-timing-function: ease-out;
&:where(:hover, :focus, :active) {
background: plum;
color: white;
}
&:checked {
background: violet;
color: white;
}
&::checkmark {
display: none;
}
&:first-child {
border: 0;
}
}
}
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
min-height: 100vh;
font-family: Arial, Helvetica, sans-serif;
background-image: radial-gradient(circle, #fcd3de, #ccc9e7);
}
*,
*::before,
*::after {
box-sizing: border-box;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.