[英]Material UI ListItem Selected Styling in React.js
I am using material-ui
ListItem
to show my nav bar items.我正在使用
material-ui
ListItem
来显示我的导航栏项目。
I wrote the following CSS code to show styling when each item selected.我编写了以下 CSS 代码来在选择每个项目时显示样式。
<List>
{routes.map(route => (
<Link to={route.path} key={route.name} style={{ textDecoration: "none" }}>
<ListItem button key={route.name} className={classes.listWrap}>
<ListItemText primary={route.name} className={classes.listItemText} />
</ListItem>
</Link>
))}
</List>;
CSS CSS
listWrap: {
"&:hover": {
border: "1px solid #6c757d",
color: "black"
},
textAlign: "center",
"&:active": {
background: "#6c757d",
color: "black"
}
}
When I select one ListItem
the styling doesn't work当我选择一个
ListItem
,样式不起作用
how can we fix?我们该如何解决?
You can use focus
instead of active
.您可以使用
focus
而不是active
。
listWrap: {
"&:hover": {
border: "1px solid #6c757d",
color: "black"
},
textAlign: "center",
"&:focus": {
background: "#6c757d",
color: "black"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.