Convert Figma logo to code with AI

miniMAC logomagic

CSS3 Animations with special effects

8,433
1,180
8,433
0

Top Related Projects

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

49,128

Modern CSS framework based on Flexbox

A utility-first CSS framework for rapid UI development.

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

Materialize, a CSS Framework based on Material Design

18,271

A lightweight and modular front-end framework for developing fast and powerful web interfaces

Quick Overview

Magic is a CSS3 animation library designed to add easy-to-use animations to web projects. It provides a collection of pre-defined animations that can be applied to HTML elements with simple class names, making it easy for developers to add engaging visual effects to their websites without writing complex CSS animations from scratch.

Pros

  • Easy to use with simple class-based implementation
  • Wide variety of pre-defined animations
  • Lightweight and minimal impact on page load times
  • Compatible with most modern browsers

Cons

  • Limited customization options without modifying the source CSS
  • Some animations may be too flashy or distracting for certain professional applications
  • Potential for overuse, which could lead to a cluttered or overwhelming user experience
  • Relies on CSS3, which may not be fully supported in older browsers

Code Examples

Adding a basic animation to an element:

<h1 class="magictime vanishIn">Hello World!</h1>

Combining multiple animations:

<div class="magictime spaceInLeft tinLeftIn">
  <p>This element will slide in from the left and tilt.</p>
</div>

Using JavaScript to trigger animations:

document.querySelector('.my-element').classList.add('magictime', 'puffIn');

Getting Started

  1. Include the Magic CSS file in your HTML:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magic/1.1.0/magic.min.css">
  1. Add the magictime class and the desired animation class to your HTML elements:
<div class="magictime swashIn">
  <p>This text will appear with a swash effect!</p>
</div>
  1. Optionally, use JavaScript to add classes dynamically for more control over when animations occur.

Competitor Comparisons

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

Pros of Bootstrap

  • Comprehensive framework with extensive components and utilities
  • Large community support and extensive documentation
  • Responsive grid system for easy layout creation

Cons of Bootstrap

  • Larger file size and potential performance impact
  • More opinionated design, which may require customization
  • Steeper learning curve for beginners

Code Comparison

Bootstrap:

<div class="container">
  <div class="row">
    <div class="col-md-6">Column 1</div>
    <div class="col-md-6">Column 2</div>
  </div>
</div>

Magic:

<div class="magic-grid">
  <div class="column">Column 1</div>
  <div class="column">Column 2</div>
</div>

Summary

Bootstrap is a feature-rich framework with extensive components and strong community support, but it comes with a larger file size and more opinionated design. Magic, on the other hand, focuses on simplicity and lightweight animations, making it easier to learn and implement for specific use cases. Bootstrap's code tends to be more verbose due to its comprehensive nature, while Magic's code is often more concise and focused on specific animation effects.

49,128

Modern CSS framework based on Flexbox

Pros of Bulma

  • More comprehensive CSS framework with a wider range of components and utilities
  • Active development with frequent updates and a large community
  • Responsive design system built-in, making it easier to create mobile-friendly layouts

Cons of Bulma

  • Larger file size due to its extensive feature set
  • Steeper learning curve for beginners compared to Magic's simplicity
  • May require more customization to achieve a unique design

Code Comparison

Magic CSS:

.magic {
  transition: all 0.3s ease-in-out;
}

Bulma CSS:

.button {
  display: inline-flex;
  justify-content: center;
  padding: calc(0.5em - 1px) 1em;
  text-align: center;
  white-space: nowrap;
}

Magic focuses on providing simple, reusable CSS animations and effects, while Bulma offers a complete CSS framework with pre-designed components and a grid system. Magic is lightweight and easy to implement for quick enhancements, whereas Bulma provides a more structured approach to building entire web layouts and interfaces.

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • Highly customizable with a comprehensive set of utility classes
  • Extensive documentation and active community support
  • Integrates well with modern JavaScript frameworks

Cons of Tailwind CSS

  • Steeper learning curve due to its utility-first approach
  • Larger initial file size before optimization
  • Can lead to verbose HTML markup

Code Comparison

Magic:

.magic {
  background: #f0f0f0;
  color: #333;
  transition: all 0.3s ease;
}

Tailwind CSS:

<div class="bg-gray-100 text-gray-800 transition-all duration-300 ease-in-out">
  <!-- Content here -->
</div>

Summary

Tailwind CSS offers a more comprehensive utility-based approach with extensive customization options, while Magic provides a simpler, more traditional CSS framework. Tailwind CSS excels in flexibility and modern development practices but may require more initial setup and learning. Magic offers a quicker start with predefined styles but less granular control over design elements.

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

Pros of Foundation

  • More comprehensive framework with a wider range of UI components and features
  • Extensive documentation and community support
  • Responsive grid system with flexible layout options

Cons of Foundation

  • Steeper learning curve due to its complexity
  • Larger file size, which may impact page load times
  • More opinionated design, potentially requiring more customization

Code Comparison

Foundation:

.button {
  @include button-style($background: $primary-color, $background-hover: scale-color($primary-color, $lightness: -15%));
}

Magic:

.button {
  background: var(--primary-color);
  transition: background 0.3s;
}
.button:hover {
  background: var(--primary-color-dark);
}

Foundation offers more built-in mixins and variables for styling, while Magic relies on CSS custom properties for a simpler approach. Foundation's code is more verbose but provides greater flexibility, whereas Magic's code is more concise and easier to understand at a glance.

Materialize, a CSS Framework based on Material Design

Pros of Materialize

  • More comprehensive UI framework with a wider range of components and features
  • Active development and community support, with regular updates and improvements
  • Better documentation and examples, making it easier for developers to implement

Cons of Materialize

  • Larger file size and potentially heavier performance impact
  • Steeper learning curve due to more complex structure and customization options
  • Less flexibility for creating unique designs, as it follows Material Design principles

Code Comparison

Magic:

.magic {
  position: relative;
  display: inline-block;
  pointer-events: none;
}

Materialize:

.btn, .btn-large, .btn-small {
  text-decoration: none;
  color: #fff;
  background-color: #26a69a;
  text-align: center;
  letter-spacing: .5px;
  transition: background-color .2s ease-out;
  cursor: pointer;
}

Magic focuses on minimal, lightweight CSS animations, while Materialize provides a full-featured CSS framework with pre-styled components. Magic's code is simpler and more focused on specific effects, whereas Materialize's code includes more comprehensive styling and functionality for various UI elements.

18,271

A lightweight and modular front-end framework for developing fast and powerful web interfaces

Pros of UIkit

  • Comprehensive front-end framework with a wide range of components and utilities
  • Extensive documentation and active community support
  • Responsive design and mobile-first approach

Cons of UIkit

  • Larger file size and potentially slower load times
  • Steeper learning curve due to its extensive feature set
  • Less focus on CSS animations compared to Magic

Code Comparison

UIkit (JavaScript):

UIkit.modal('#my-modal').show();

Magic (CSS):

.magic {
  animation: magic 1s;
}

UIkit provides a more structured approach to building user interfaces with JavaScript-based components, while Magic focuses on pure CSS animations and transitions. UIkit offers a complete framework for web development, whereas Magic is specifically designed for adding CSS animations to elements.

UIkit is better suited for larger projects requiring a full-featured framework, while Magic is ideal for developers looking to add quick and easy CSS animations to their existing projects without additional JavaScript dependencies.

The choice between these two repositories depends on the project requirements, with UIkit offering more comprehensive features and Magic providing a lightweight solution for CSS animations.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

:tophat: magic

CSS3 Animations with special effects. (→ 3.1 kB gzip)

Demo

Checkout the demo for the animations here

Table of Contents

Installation

GitHub Package Registry - Package url

npm install @minimac/magic.css

NPM - Package url

npm i magic.css

YARN - Package url

yarn add magic.css

Getting Started

Include the file magic.css or include the minified version magic.min.css

<link rel="stylesheet" href="yourpath/magic.css">

or

<link rel="stylesheet" href="yourpath/magic.min.css">

Usage with JavaScript

This is a sample code for on hover effect with JavaScript. First, Include the class magictime and then a desired animation class.

const selector = document.querySelector('.yourdiv')
selector.classList.add('magictime', 'puffIn')

If you want to load the animation after certain time, you can use this example:

//set timer to 5 seconds, after that, load the magic animation
function myFunction() {
    const selector = document.querySelector('.yourdiv')
    selector.classList.add('magictime', 'puffIn')
}
setTimeout(myFunction, 5000);

If you want to load the animation after certain time but with an infinite loop, you can use this example:

//set timer to 3 seconds, after that, load the magic animation and repeat forever
function myFunction() {
    const selector = document.querySelector('.yourdiv')
    selector.classList.add('magictime', 'puffIn')
}
setInterval(myFunction, 3000);

Usage with jQuery

This is a sample code for on hover effect with jQuery. First, Include the class magictime and then the desired animation class.

$('.yourdiv').hover(function () {
    $(this).addClass('magictime puffIn');
});

If you want to load the animation after certain time, you can use this example:

//set timer to 5 seconds, after that, load the magic animation
setTimeout(function(){
    $('.yourdiv').addClass('magictime puffIn');
}, 5000);

If you want to load the animation after certain time but with infinite loop, you can use this example:

//set timer to 3 seconds, after that, load the magic animation and repeat forever
setInterval(function(){
    $('.yourdiv').toggleClass('magictime puffIn');
}, 3000 );

HTML & CSS tips

You can change the time of the animation by setting the class magictime for example:

.magictime {
    -webkit-animation-duration: 3s;
    animation-duration: 3s;
}

Default CSS timing is:

.magictime {
    -webkit-animation-duration: 1s;
    animation-duration: 1s;
}

If you want to assign the timing to a specific animation, you can use the following code (use 2 class):

.magictime.magic {
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
}

Animation Classes

MAGIC EFFECTSBLINGSTATIC EFFECTSSTATIC EFFECTS OUTPERSPECTIVEROTATE
magicpuffInopenDownLeftopenDownLeftOutperspectiveDownrotateDown
twisterInDownpuffOutopenDownRightopenDownRightOutperspectiveUprotateUp
twisterInUpvanishInopenUpLeftopenUpLeftOutperspectiveLeftrotateLeft
swapvanishOutopenUpRightopenUpRightOutperspectiveRightrotateRight
openDownLeftReturnperspectiveDownReturn
openDownRightReturnperspectiveUpReturn
openUpLeftReturnperspectiveLeftReturn
openUpRightReturnperspectiveRightReturn
SLIDEMATHTINBOMBBOINGON THE SPACE
slideDownswashOuttinRightOutbombRightOutboingInUpspaceOutUp
slideUpswashIntinLeftOutbombLeftOutboingOutDownspaceOutRight
slideLeftfoolishIntinUpOutspaceOutDown
slideRightholeOuttinDownOutspaceOutLeft
slideDownReturntinRightInspaceInUp
slideUpReturntinLeftInspaceInRight
slideLeftReturntinUpInspaceInDown
slideRightReturntinDownInspaceInLeft

:tada: Gulp and SCSS (SASS) compiling

If you want to customize the CSS files, now you will have the chance. For example, if you want to include only certain animations, you will have to go to this file:

assets/scss/magic.scss

Comment or uncomment your desired file and run from terminal the following commands:

npm install

and last command:

gulp

Automatically this generate the new files!

:white_check_mark: Browser Support

BrowserChromeFirefoxSafariiOS SafariOperaAndroidAndroid ChromeIEOpera Mini
Version31+31+7+7.1+27+4.1+42+10+:x: