<div class="cp_ipselect06">
<select class="cp_sl06" required>
<option value="" hidden disabled selected></option>
<option value="1">cat</option>
<option value="2">dog</option>
<option value="3">rabbit</option>
<option value="4">squirrel</option>
</select>
<span class="cp_sl06_selectbar"></span>
<label class="cp_sl06_selectlabel">Choose</label>
</div>
.cp_ipselect06 {
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
margin: 2em auto;
}
.cp_ipselect06 .cp_sl06 {
position: relative;
width: 100%;
height: 48px;
cursor: pointer;
text-overflow: ellipsis;/*テキストがオーバーしたら'...'で省略*/
z-index: 1;
/* 標準のスタイルを無効にしborder-bottomを設定 */
border: none;
appearance: none;
outline: none;
background: transparent;
border-radius: 0;
border-bottom: 1px solid #666666;
}
/*プルダウンの三角を設定*/
.cp_ipselect06::after {
position: absolute;
right: 15px;
content: '';
width: 16px;
height: 8px;
background: #666666;
clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.cp_sl06_selectlabel {
position: absolute;
left: 0;
top: 10px;
color: #666666;
transition: 0.2s ease all;
}
/*選択した際の動き:「Choose」の文字*/
.cp_sl06:focus ~ .cp_sl06_selectlabel,
.cp_sl06:valid ~ .cp_sl06_selectlabel {
color: #da3c41;
top: -20px;
transition: 0.2s ease all;
font-size: 80%;
}
/*選択した際の動き:セレクト下のライン*/
.cp_sl06_selectbar {
position: relative;
display: block;
width: 100%;
}
.cp_sl06_selectbar:before,
.cp_sl06_selectbar:after {
bottom: 1px;
content: '';
width: 0;
height: 2px;
position: absolute;
background: #da3c41;
transition: 0.2s ease all;
}
.cp_sl06_selectbar:before {
left: 50%;
}
.cp_sl06_selectbar:after {
right: 50%;
}
/*focus時の設定*/
.cp_ipselect06 .cp_sl06:focus {
border-bottom: 1px solid transparent;
}
.cp_sl06:focus ~ .cp_sl06_selectbar:before,
.cp_sl06:focus ~ .cp_sl06_selectbar:after {
width: 50%;
}