LESS CSS Pass mixin as a parameter to another mixin

后端 未结 4 1655
借酒劲吻你
借酒劲吻你 2020-12-08 11:49

Is there any way to pass one mixin or style\'s declaration to another mixin as an input parameter?

Let\'s take a look at an example with animation keyframes. Followi

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 12:29

    You can also use my solution to generate CSS keyframes: https://github.com/thybzi/keyframes

    Features:

    • Cross-browser keyframes generation (Firefox 5+, Chrome 3+, Safari 4+, Opera 12+, IE 10+)
    • Up to 16 timepoints in each keyframes rule (and the number can be easily augmented, if needed)
    • Mixins, variables and functions can be used for styling timepoints
    • Keyframes are created separately from animation rules, so:
      • multiple animation rules can use the same keyframe with different values for timing, repeating, etc,
      • multiple animations can be used within same animation rule
      • animations can be applied (not created!) inside any parent selector
    • Lightweight and (almost) neat LESS code

    Basic usage:

    // Preparing styles for animation points
    .keyframes-item(fadeIn, 0%) {
        opacity: 0;
    }
    .keyframes-item(fadeIn, 100%) {
        opacity: 1;
    }
    // Generating keyframes
    .keyframes(fadeIn);
    
    // Applying animation to fade-in block in 1.5 seconds
    .myBlock {
        .animation(fadeIn 1.5s);
    }
    

提交回复
热议问题