Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:36:15+00:00 2026-06-05T21:36:15+00:00

While I was writing many quasi-identical CSS3 animations , I wondered if there’s a

  • 0

While I was writing many quasi-identical CSS3 animations, I wondered if there’s a way to shorten the code.
Each time, only the final keyframe is different.

@-webkit-keyframes one {
    from {
        [identical properties]
    }
    [...etc...]
    80% {
        [identical properties]
    }
    to {
        margin-left: 20px;
    }
}

@-webkit-keyframes two {
    from {
        [identical properties]
    }
    [...etc...]
    80% {
        [identical properties]
    }
    to {
        margin-left: 50px;
    }
}

That code is pretty long so I thought it could be easily shortened but looks like you have to define the whole animation over and over.
I tried something like this, but that doesn’t work in Chrome and Safari.

@-webkit-keyframes one, two {
    from {
        [identical properties]
    }
    [...etc...]
    80% {
        [identical properties]
    }
    to {
        margin-left: 20px;
    }
}

@-webkit-keyframes two {
    to {
        margin-left: 50px;
    }
}

Is there no way to define 2 identical animations? 😮

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:36:18+00:00Added an answer on June 5, 2026 at 9:36 pm

    To avoid copy-pasting during development, you can use a CSS preprocessor, such as SCSS / SASS and LESS. The mixin feature greatly reduces the code size:

    For a single property, writing a single mixin is sufficient:

    .Duplicates(@marginLeft) {
        from { /* ... */ }
        80%  { /* ... */ }
        to { margin-left: @marginLeft;}
    }
    @-webkit-keyframes one {
        .Duplicates(20px);
    }
    @-webkit-keyframes two {
        .Duplicates(50px);
    }
    

    Demo: An animated busy supermarket, using pure CSS(3)

    For me, the previous mixin was not sufficient. I also wanted dynamic names and vendor-prefixes how?, so that I do not have to write a rule 10 x 5 = 50 times (10 names, 5 vendors). That’s a chance to show the power of a CSS preprocessor:

    • Input (less) – http://pastebin.com/BcRYzdBj – 3kB
    • Output (css) – http://pastebin.com/zLCS2z7L – 14kB (Gzipped 999 bytes)
    • Demo (source): http://jsfiddle.net/ecPWA/show/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While writing some C code, I decided to compile it to assembly and read
While writing code in a file that would comprise of PHP, HTML, CSS &
While writing code, it is pretty common to request a page with an appended
While writing a card shuffling algorithm I realized that there are 52! ~= 2^225
I am launching many threads simultaneously, each one writing / reading data into/from a
Many times while writing functions that accept enumerable types I face this confusion. Which
While I've been writing php for a long time, it was always a skill
While writing UI automation tests I come across forms with many fields and instead
All, While writing a test method for method A (which has many internal conditions),
While writing an encryption method in JavaScript, I came to wondering what character encoding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.