Recently, I updated my portfolio (johnrhea.com – check it out if you need a front-end engineer with animation and storytelling skills!). I repurposed some planetary animations from a past project. Initially, I just integrated them, scaling them using viewport units (a feat of mathematical prowess I was quite proud of!). However, on mobile, a subtle vertical jitter appeared during the moon's orbit. This led me to optimize the animation, resulting in this article.
Here's the original, unwieldy animation (141 lines!):
View Original Code
```
moon1 {
animation: moon-one 60s infinite; }
@keyframes moon-one { / ... (Original 141-line keyframes omitted for brevity) ... / }
The keyframes were unnecessarily repeated five times. By reducing the animation duration to 12 seconds and removing redundant code, I trimmed it to 36 lines:
moon1 {
animation: moon-one 12s infinite; }
@keyframes moon-one { / ... (36-line optimized keyframes omitted for brevity) ... / }
<code> Further optimization involved simplifying keyframe percentages (0%, 25%, 50%, 75%, 100%) and rounding viewport units to the nearest tenth. This resulted in: </code>
moon1 {
animation: moon-one 12s infinite; }
@keyframes moon-one { / ... (Shorter optimized keyframes omitted for brevity) ... / }
<code> The next improvement involved separating `translate` and `scale` from the `transform` property into individual properties. This allowed for more control and smoother animation. Unnecessary `translate` properties were removed, letting browser interpolation handle smooth transitions. </code>
moon1 {
animation: moon-one 12s infinite; }
@keyframes moon-one { / ... (Further optimized keyframes omitted for brevity) ... / }
<code> Finally, I standardized the animation timing function to `ease-in-out` for a more consistent and natural look. The final, concise code (28 lines): </code>
moon1 {
animation: moon-one 12s infinite ease-in-out; }
@keyframes moon-one { 0%, 100% { translate: 0 0; scale: 1; z-index: 2; } 25% { scale: 1.5; } 49.9% { z-index: 2; } 50% { translate: -5vw 6.5vw; scale: 1; z-index: -1; } 75% { scale: 0.25; } 99.9% { z-index: -1; } }
<code> The animation now looks improved and is significantly more maintainable. What optimization steps did I miss? Let me know in the comments!</code>
? ??? ?? ?? (?? CSS ? ??? ?????? ????? ??)? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

AutoPrefixer? ?? ???? ??? ???? ?? ?? ???? CSS ??? ???? ???? ?????. 1. ????? ???? ???? ???? ??? ?????. 2. PostCSS ???? ??, CSS? ?? ???? ???? ?? ???? ??? ???? ??? ?? ??? ?????. 3. ?? ???? ???? ??, ??????? ?? ? ?? ???????? ????? ?? ?????. 4. ???? ???? ???? ???? ?? ?? ????, ???? ?? ??? ?? ???? ???? ????? ?? ???? ?? ????.

ToTeCreatesTickyHeaders andfooterswithcss, ?? ?? : stickyforheaderswithTopvalueAndz-index

CSS?? ????? ??? ? ?? ??? ????. 1. HTML ? CSS? ?? ??? ?????? ???? ?? ???? ?? ???? ??????. 2. ?? ??? ??? ?? ???? ???? ?? ?? ??? ?? ?? ??? ??????. 3. ??? ????? ???? JavaScript? ?? ???? ?????? ??? ?????. ? ?? ??? ??? ??? ????? ?? ??, ??, ??? ? ?? ???? ?? ?? ?? ??? ???? ?????.

Mobile-FirstcsSdesignRequiresTtingTheviewPortMetatag, RelativeUnits, StylingFromsMallScreensup, ??? ???? andtouchtargets.first, addtocontrolscaling.second, ??%, em, orreminsteadofpixelsforflexelayouts.third

?? ?? ? ??? ????? ????? ?? ??? CSSGrid? ?? (Auto-Fit, Minmax ()) ??? ???? ????. 1. ???-???-?? ?? : ?? (?? ??, minmax (200px, 1fr)) ????? ?? ?? ???? ???? ? ?? ?? ? ?? ??? ????????. 2. ??? ???? ??? ??? ??????. 3. ????? ?? ?? ?? ??? ??????? 100%, ?? ?? : ?? ?? ??? ??? ???? ??? ?????? Border-Box? ???????. 4. ????? ?? ?? ??? ???? ????? ?? ? ??? ??? ??? ?????.

???? ?? ??? ????? ???? ???? ?? ???? ?? ? ? ????. 1. ?? : 0auto ?? ?? ???? ???? ?? ????? ??? ?? ??? ????? ????? ???????. 2. Flexbox? ???? ?? ?????? ??? ? ?? ?? ??? ???? ??? : 100VH? ???? ?? ? ?? ???? ???? ?? ?? ????? ????? ?????. 3. CSSGRID? ?? ?? ??? ???? ?? ????? ??? ???? ???? ?? ????? ?????? ??? ?? ????? ??? ???? ???????. ? ???? ?? ??? ???? ? ?? ??? ???? ?? ??? ?? ??? ???? ??????.

feacturedetectionincssusing@supportschecksifabrowsersupportseaspecificfeaturebeforplyplyplatedstyles.1.itusesconditionalcssblocksbasedonproperty-valuepair, sublics@supports (display : grid)

CSS ???? ??? ? ??? ??? ????? ???? ??? ???? ???? ?? ?? ???? ????? ???????. 1. Flexbox ? ??? ??? ?? ???? ??? ??, ?? : ??? ?? ? ????? ??? ????. 2. Caniuse ?? ?? ?? ??? ??????. 3. -webkit-, -moz-, -ms-, -o- ? ?? ???? ???? ???? ?????. 4. AutoPrefixer? ???? ???? ???? ???? ?? ????. 5. ?? ????? ????? PostCSS? ???? BrowsersList? ??????. 6. ?? ? ???? ???? ?????. 7. Modernizr ?? ??? ??? ????? ??? ? ????. 8. ?? ????? ???? ?? ? ??? ????.
