当前,标签位于边框之外。
如何使单词“from:”位于下拉框的顶部,并且当值被选中时它仍然存在?
样本输出:出发地:选项2
<div class="custom-select">
<label for="dropdown">from: </label>
<select >
<option value="" disabled selected>From:</option>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>
</div>
.custom-select {
position: relative;
display: inline-block;
width: 100%;
font-size: 16px;
overflow: hidden;
}
.custom-select select {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
padding: 8px 30px 8px 16px;
border: 1px solid #ccc;
background-color: white;
width: 100%;
cursor: pointer;
background-repeat: no-repeat;
background-position: right center;
}
.custom-select select::-ms-expand {
display: none;
}
.custom-select select:focus {
outline: none;
}
.select-label {
position: absolute;
top: 50%;
right: 10px;
transform: translateY(-50%);
font-weight: bold;
color: #555;
}
1条答案
按热度按时间mwg9r5ms1#
你好,有尝试下面的代码,我已经做了使用引导