css - 如何覆盖 Material-UI 中 Native Select 的下拉项/选项的样式?
问题描述
const styles = makeStyles((theme) => ({
dropDownFormSize: { width: '60%' },
dropDownSelector: {
// fontFamily: 'Comfortaa',
fontSize: '15px',
},
optionDropdown: {
paddingLeft: '10px',
color: 'white',
},
option: {
color: 'white',
border: `1px solid ${theme.palette.primary.contrastText}`,
'&:focus': {
border: `1px solid ${theme.palette.secondary.contrastText} !important`,
},
},
optionItems: {
// work on the hover
backgroundColor: `${theme.palette.primary.light} !important`,
// this hover do not get triggered unless I trigger it from
//the dev tool
'&:hover': {
backgroundColor: ` ${theme.palette.secondary.contrastText} !important`,
},
},
}));
const dummyElement = () => {
const classes = styles();
const languageArray = ['English', 'Mexican', 'Italian', 'Persian'];
return (
<FormControl className={classes.dropDownFormSize}>
<NativeSelect
required
className={classes.dropDownSelector}
value={language}
name='language'
onChange={handleChangeLanguage}
classes={{
root: classes.optionDropdown,
select: classes.option,
}}
>
<option
value=''
disabled
className={classes.optionItems}
>
Select Option
</option>
{languageArray.map((language, i) => {
return (
<option
key={i}
className={classes.optionItems}
value={language}
>
{language}
</option>
);
})}
</NativeSelect>
</FormControl>
);
}
问题是当我将鼠标悬停在本机选择中的选项上时,不会触发选项的悬停(如果我从开发工具触发 :hover,则应用样式)。当我将鼠标悬停在项目上时,有一些白色背景,我试图覆盖它,但我在检查器中找不到它的样式。
解决方案
推荐阅读
- c - 包含glad.h时的分段错误
- spring - 在一个类上声明@configuration 会使其成为一个spring bean吗?
- entity-framework - 我应该有多少个 DbContext 类?
- lua - 使用纯 Lua 脚本对齐的文本自动换行
- c++ - 将 lambda 一般存储在 constexpr 结构中
- java - Java Timer Countdown 从某个时间开始
- flask - 如何使用 GET/POST 将 GET 发送到烧瓶
- computation-theory - 计算以下代码的代码复杂度
- llvm - clang-tidy 未能通过错误检查
- mysql - Mysql 查询匹配以检查查询是否已更新