我已经用MaterialUI创建了一个图片列表,现在我想添加鼠标悬停效果来突出显示鼠标光标下的图片。下面是我的图片列表代码。我如何实现这一点?
<Box
sx={{
height: 450,
marginLeft: "10em",
backgroundColor: "white",
display: "grid",
gridTemplateColumns: {
mobile: "repeat(1, 1fr)",
bigMobile: "repeat(2, 1fr)",
tablet: "repeat(3, 1fr)",
desktop: "repeat(4, 1fr)",
},
[`& .${imageListItemClasses.root}`]: {
display: "flex",
flexDirection: "column",
}
}}
>
<ImageList
variant="quilted"
sx={{ width: 2000, height: 1000, margin: "5em" }}
cols={3}
rowHeight={500}
>
{cardsList.map((item, index) => (
<div>
<ImageListItem key={index}>
<img
src={"data:image/jpeg;base64," + item.content}
alt={item.fileName}
/>
</ImageListItem>
</div>
))}
</ImageList>
</Box>
1条答案
按热度按时间gmxoilav1#
将ImageListItem更改为具有悬停样式的自定义项,如下所示..尽管我个人不喜欢MUI v5.11中样式元素的新方式