我有一个简单的select,最多需要保持200px宽度。我遇到的问题是较长的文本出现在背景图像的顶部。
我怎样才能得到它以便选择保留200px,然后,如果存在更长的文本,它不会与下拉箭头重叠?
select{
width: 200px;
border: 0;
background: #fff url(https://f.hubspotusercontent00.net/hubfs/2367000/select_arrow.png/medium.png?t=1592558417346);
background-size: 20px;
background-repeat: no-repeat;
background-position: right 25px center;
background-size: 15px;
-webkit-appearance: none;
-moz-appearance: none;
padding: 10px 15px;
border: 1px solid #B8B9BA;
outline:none;
border-radius: 26px;
}Run Code Online (Sandbox Code Playgroud)
<select>
<option>This option here is really long</option>
<option>Medium length option</option>
<option>short</option>
</select>Run Code Online (Sandbox Code Playgroud)
只需增加正确的填充。
select{
width: 200px;
border: 0;
background: #fff url(https://f.hubspotusercontent00.net/hubfs/2367000/select_arrow.png/medium.png?t=1592558417346);
background-size: 20px;
background-repeat: no-repeat;
background-position: right 25px center;
background-size: 15px;
-webkit-appearance: none;
-moz-appearance: none;
padding: 10px 50px 10px 15px;
border: 1px solid #B8B9BA;
outline:none;
border-radius: 26px;
}Run Code Online (Sandbox Code Playgroud)
<select>
<option>This option here is really long</option>
<option>Medium length option</option>
<option>short</option>
</select>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
141 次 |
| 最近记录: |