【发布时间】:2021-07-13 18:39:02
【问题描述】:
我有使用材质 UI 的卡片组件。卡片在悬停时变形,卡片上也应该出现阴影。但是当我把 box-shadow 阴影出现在变形前的盒子上时,变形后的卡片和阴影之间有空白。我该如何解决这个问题?
const CardStyle = styled(Card)`
background: red;
transition: transform 50ms;
&:hover {
transform: scale(1.02) perspective(0px);
box-shadow: ${({ theme }) => theme.shadows[4]};
}
`;
其他方式相同的输出:
:hover {
transform: scale(1.02) perspective(0px);
box-shadow: 4px 4px 4px rgba(60, 60, 93, 0.33)
}
【问题讨论】:
-
什么是
theme.shadows[4]?是否有一些 x、y 偏移量? -
是的,这是阴影尺寸的偏移量。
标签: css material-ui transform card