el-select设置下拉框背景
时间: 2023-08-07 18:08:04 浏览: 116
el-select设置下拉框背景可以通过修改样式来实现。根据引用\[2\]中的代码,可以给下拉框内容添加背景色。通过修改.el-select-dropdown__item.selected、.el-select-dropdown__item:hover和.el-select-dropdown__item.hover的样式,可以设置下拉框的背景色。例如,可以设置背景色为蓝色,代码如下:
.el-select-dropdown__item.selected,
.el-select-dropdown__item:hover,
.el-select-dropdown__item.hover {
color: #fff;
background: #409EFF;
}
这样设置后,下拉框的选中项、鼠标悬停项和.hover状态的项都会有蓝色的背景色。如果需要解决鼠标移出下拉框时背景色不消失的问题,可以将.el-select-dropdown__item.hover和.el-select-dropdown__item:hover的背景色改为白色,代码如下:
.el-select-dropdown__item.hover,
.el-select-dropdown__item:hover {
background-color: #fff;
}
.el-select-dropdown__item.selected,
.el-select-dropdown__item:hover {
color: #fff;
background: #409EFF;
}
这样设置后,鼠标移出下拉框时,hover状态的背景色会消失,而选中项的背景色仍然保持蓝色。这样就可以实现el-select下拉框的背景设置。
#### 引用[.reference_title]
- *1* [el-select隐藏下拉框](https://blog.csdn.net/qq_41838435/article/details/122877185)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [element的el-select给下拉框添加背景以及鼠标离开背景色不消失问题](https://blog.csdn.net/m0_52539553/article/details/124857417)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [ElementUI中el-select设置下拉框选项内容和选中项内容不一致](https://blog.csdn.net/qq_41314371/article/details/128329280)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文