2025-01-09 07:04:00
css-tip.com
Skip to main content
Using the new @starting-style
you can create animations without using @keyframes
. It’s not a replacement for the classic way to create animations but it can be a useful CSS trick in some situations.
Here is a simple example with a rotation. I am using big values to simulate an infinite rotation.
.box {
transition: 40s linear 1s;
rotate: 0turn;
@starting-style {
rotate: -20turn;
}
}
See the Pen
Infinite rotation without keyframes by Temani Afif (@t_afif)
on CodePen.
Here is a more generic example where I animate one variable and then use it within different properties
@property --i {
syntax: "" ;
inherits: false;
initial-value: 1000;
}
.box {
background: hsl(calc(var(--i)*10) 80% 50%);
translate: 0 calc(sin(var(--i))*20px);
rotate: calc(clamp(0,mod(var(--i),10) - 5,1)*90deg);transition: --i 120s linear 1s;
@starting-style {
--i: 0;
}
}
See the Pen
Complex animation without keyframes by Temani Afif (@t_afif)
on CodePen.
Again, I am not saying it’s better than an animation
combined with keyframes
. It’s just a different way to express animations.
More CSS Tips
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.