【发布时间】:2021-11-16 20:57:44
【问题描述】:
我是动画新手,但我想为骨架加载器制作动画。我希望它以 0% 的宽度从左侧开始,然后以 100% 的宽度向右移动,然后让加载程序变为零但反向,以便它以 0% 的宽度在右侧结束。我的问题是我无法让动画从左到右消失。我正在使用带有样式的组件的反应。这是我的代码:
const reveal = keyframes`
0% {
width: 0%;
}
50% {
width: 100%;
}
100% {
width: -100%;
}
`;
const StyledSkeleton = styled.div`
height: 40px;
font-size: 64px;
line-height: 70px;
overflow: hidden;
background-color: ${colors.LOADER_BACKGROUND};
background-size: 100%;
animation-name: ${reveal};
animation-duration: 2s;
animation-timing-function: ease-in;
animation-delay: 0s;
animation-iteration-count: infinite;
animation-direction: normal;
`;
【问题讨论】:
标签: javascript css animation styled-components