我只想设置下拉菜单的样式,有什么选择吗?另外,应用自定义箭头。
<select onChange={displayProjectBy}>
<option value="MOST_POPULAR">Most Popular</option>
<option value="NEWEST">Newest</option>
<option value="OLDEST">Oldest</option>
<option value="NAME_ASC">Name A-Z</option>
<option value="NAME_DESC">Name Z-A</option>
</select>
select {
outline: 0;
border-color: $color-gainsboro;
border-radius: 10px;
color: $color-black;
font-weight: 700;
padding-left: 20px;
float: right;
width: 100%;
}
答案 0 :(得分:0)
不幸的是,您必须创建自己的下拉菜单才能实现。这是一个示例,您可以如何做(所有功劳https://www.w3schools.com/的功劳):
<div class="custom-select" style="width:200px;">
<select>
<option value="0">Select car:</option>
<option value="1">Audi</option>
<option value="2">BMW</option>
<option value="3">Citroen</option>
<option value="4">Ford</option>
<option value="5">Honda</option>
<option value="6">Jaguar</option>
<option value="7">Land Rover</option>
<option value="8">Mercedes</option>
<option value="9">Mini</option>
<option value="10">Nissan</option>
<option value="11">Toyota</option>
<option value="12">Volvo</option>
</select>
</div>
CSS:
/* The container must be positioned relative: */
.custom-select {
position: relative;
font-family: Arial;
}
.custom-select select {
display: none; /*hide original SELECT element: */
}
.select-selected {
background-color: DodgerBlue;
}
/* Style the arrow inside the select element: */
.select-selected:after {
position: absolute;
content: "";
top: 14px;
right: 10px;
width: 0;
height: 0;
border: 6px solid transparent;
border-color: #fff transparent transparent transparent;
}
/* Point the arrow upwards when the select box is open (active): */
.select-selected.select-arrow-active:after {
border-color: transparent transparent #fff transparent;
top: 7px;
}
/* style the items (options), including the selected item: */
.select-items div,.select-selected {
color: #ffffff;
padding: 8px 16px;
border: 1px solid transparent;
border-color: transparent transparent rgba(0, 0, 0, 0.1) transparent;
cursor: pointer;
}
/* Style items (options): */
.select-items {
position: absolute;
background-color: DodgerBlue;
top: 100%;
left: 0;
right: 0;
z-index: 99;
}
/* Hide the items when the select box is closed: */
.select-hide {
display: none;
}
.select-items div:hover, .same-as-selected {
background-color: rgba(0, 0, 0, 0.1);
}