CSS动画可以为从一种CSS样式配置到另一种CSS样式配置的转换设置动画。 CSS模块描述了作者使用关键帧随时间动画CSS属性值的方法。可以通过指定这些关键帧动画的持续时间,重复次数和重复行为来控制这些关键帧动画的行为。
我正在尝试添加一个简单的动画,该动画的雪花在容器中从上到下掉落: 这里链接:
import "./styles.css"; const seasonArray = ["winter", "summer", "autumn"]; const getSeasonValue = (season) => { switch (season) { case "winter": return winter; case "autumn": return autumn; case "summer": return summer; default: return summer; } }; const StyledButton = styled.button` border: 1px solid black; border-radius: 10px; padding: 5px; display: flex; justify-content: center; align-items: center; max-width: 33%; position: relative; min-width: 30%; height: 20%; `; const StyledButtonsWrapper = styled.div` display: flex; justify-content: space-between; height: 100vh; `; export default function App() { return ( <StyledButtonsWrapper> {seasonArray.map((season) => { return ( <StyledButton key={season} label={season}> <SnowFlakeIcon /> {season.charAt(0).toUpperCase()} {season.substring(1)} </StyledButton> ); })} </StyledButtonsWrapper> ); } const StyledSvg = styled.svg` position: absolute; top: 0; width: 100% height: 100%; animation: snowFlake 2s ease-in-out infinite; @keyframes snowFlake { 0% { transform: translateY(0); } 50% { transform:translateY(50%); } 100% { transform: translateY(100%); } } `; const SnowFlakeIcon = () => { return ( <StyledSvg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <path d="m10 20-1.25-2.5L6 18" fill="#88C9F9" /> <path d="M10 4 8.75 6.5 6 6" fill="#88C9F9" /> <path d="m14 20 1.25-2.5L18 18" fill="#88C9F9" /> <path d="m14 4 1.25 2.5L18 6" fill="#88C9F9" /> <path d="m17 21-3-6h-4" fill="#88C9F9" /> <path d="m17 3-3 6 1.5 3" fill="#88C9F9" /> <path d="M2 12h6.5L10 9" fill="#88C9F9" /> <path d="m20 10-1.5 2 1.5 2" fill="#88C9F9" /> <path d="M22 12h-6.5L14 15" fill="#88C9F9" /> <path d="m4 10 1.5 2L4 14" fill="#88C9F9" /> <path d="m7 21 3-6-1.5-3" fill="#88C9F9" /> <path d="m7 3 3 6h4" fill="#88C9F9" /> </StyledSvg> ); };
可以将nth-child值用作属性中的参数吗? (以及如何)
肖特描述(TL; dr;) 是否有使用CSS属性内的n-Child值的“纯CSS”方式(不是/sass)?这样的事情: span.anim:nth-child(n){animation-delay:...
我想创建这种效果,其中一个圆将同时扩展到左右。我在另一篇文章中看到了这个答案:
如何制作CSS剪贴显示背景背景,而仅在剪裁的部分中应用动画?
@keyframes expandCircle { 0% {clip-path: circle(0% at center);} 100% {clip-path: circle(100% at center);}} @keyframes melt { 0% { filter: blur(20px) contrast(400%) saturate(250%) brightness(125%); pointer-events: none;} 100% { filter: none; pointer-events: all;}} #screen-container { position: absolute; width: 100%; height: 100%; background-image: url("system/wallpaper/paint.bmp"); background-repeat: no-repeat; background-size: cover; background-color: #000000; animation: expandCircle 3s forwards; clip-path: inset(0 0 0 0 round 8px); /* contain the blur */ overflow: hidden; } #screen-container::after { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: inherit; clip-path: circle(0% at center); animation: melt 2s forwards; }
我有一个我正在处理的切换条元件,目前我可以正确地使用它来样式切换按钮,但是我想要更多的动画。