DEV Community

FSCSS tutorial for FSCSS tutorial

Posted on

⚡ FSCSS Ultra-Shorthand Animations — Assign Keyframes in One Line

FSCSS isn’t just a CSS shortcut — it’s a compression engine for styling.
One of the coolest features is how you can define @keyframes and assign animations to multiple selectors in one single shorthand line.

Here’s a clean example.


Ultra-Shorthand @keyframes Assignment

Instead of writing long CSS like:

@keyframes trans {
  from { 
width: 0; 
height: 0; 
background: red;
 }
  to { 
width: 200px; 
height: 200px; 
background: blue; 
}
}

.box, .card {
  animation: trans 3s ease-in infinite alternate;
}
Enter fullscreen mode Exit fullscreen mode

FSCSS lets you compress all of that into this:

$(@keyframes trans, .box, .card &[3s ease-in infinite alternate]){
  from {
    %2(width, height [: 0;]) 
    background: red;
  } 
  to {
    %2(width, height [: 200px;])
    background: blue;
  }
}
Enter fullscreen mode Exit fullscreen mode

And that’s it.
One line declares:

  • The keyframes name

  • The selectors (.box, .card)

  • The animation settings

  • And the full animation body

All wrapped inside $().


🧩 Breakdown

✔ Declare @keyframes, selectors, and animation timing together:

$(@keyframes trans, .box, .card &[3s ease-in infinite alternate])

%2() sets two properties at once:

%2(width, height [: 0;])
%2(width, height [: 200px;])

✔ Clean from → to animation


Quick try


<script src="https://cdn.jsdelivr.net/npm/fscss@1.1.11/exec.min.js" defer>
</script>

<style>
div{
  margin: 10px;
}
$(@keyframes trans, .box, .card &[3s ease-in infinite alternate]){
  from {
    %2(width, height [: 0;]) 
    background: red;
  } 
  to {
    %2(width, height [: 200px;])
    background: blue;
  }
}
</style>

<div class="box">
</div>

<div class="card">
</div>
Enter fullscreen mode Exit fullscreen mode

💙 Why This Is Useful

Write animations faster

Assign animations to many elements at once

Avoid repetitive animation: ... lines

Shrink your CSS dramatically

Keep your code clear and elegant

If you build UI components, loaders, or hover effects often, this technique saves minutes of typing on every project.


FSCSS takes classic CSS features (like keyframes) and turns them into compact, flexible super-syntax.
If you enjoy writing beautiful animations with less noise, this shorthand style is a game-changer.

More tips coming soon 😎🔥


Top comments (0)