(这是针对选项菜单选项的特定样式,而不是样式选择菜单的整体样式/无法设置)
我想知道如何在选择菜单中选中的选项溢出时淡出文本。例如,在JSFiddle中,“Mercedes”此刻被切割,它将使用CSS渐变背景样式淡出边缘。
这是一个类似的答案,但我似乎无法在选择菜单上工作,也许这是不可能的?
<div class="selectbox">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</div>
CSS:
.selectbox {
border: 1px solid #ccc;
width: 50px;
border-radius: 3px;
background: #fafafa no-repeat 90% 50%;
}
.selectbox select:after {
content: '';
position: absolute;
top: 0;
right: 0;
width: 30%;
height: 100%;
position: absolute;
right: 0;
bottom: 0;
width: 100%;
height: 50%;
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background-image: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%); pointer-events: none;
}
.selectbox select {
padding: 5px 8px;
width: 100%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
background: #fafafa no-repeat 90% 50%;
}
.selectbox select:focus {
outline: none;
}
以下是https://jsfiddle.net/nick_1002/7y5uezs5/
的尝试非常感谢任何帮助:)