Convert Figma logo to code with AI

chokcoco logomagicCss

CSS3奇思妙想,单标签实现各类图形

1,437
289
1,437
4

Top Related Projects

46,619

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API

47,953

Parse, validate, manipulate, and display dates in javascript.

34,434

⏳ Modern JavaScript date utility library ⌛️

144,559

JavaScript Style Guide

Quick Overview

The chokcoco/magicCss repository is a collection of creative and visually stunning CSS effects and animations. It showcases the power of CSS to create unique and captivating visual experiences without the need for complex JavaScript.

Pros

  • Diverse Collection: The repository contains a wide variety of CSS effects, ranging from simple hover animations to complex 3D transformations, catering to various design needs.
  • Reusable Code: The provided code examples are well-structured and can be easily integrated into different projects, saving developers time and effort.
  • Detailed Documentation: The repository includes detailed documentation, including code snippets and explanations, making it easy for developers to understand and implement the effects.
  • Inspiration and Learning: The project serves as an excellent resource for designers and developers to explore the possibilities of CSS and gain inspiration for their own projects.

Cons

  • Limited Customization: While the effects are visually impressive, the level of customization may be limited, as the code is primarily focused on showcasing the CSS capabilities.
  • Performance Considerations: Some of the more complex effects may have performance implications, especially on older or less powerful devices, which developers should be mindful of.
  • Dependency on Modern Browsers: Many of the effects rely on the latest CSS features, which may not be fully supported by older browsers, potentially limiting the project's cross-browser compatibility.
  • Lack of Interactive Demos: While the documentation provides code examples, the absence of interactive demos may make it harder for users to visualize and experiment with the effects.

Code Examples

Example 1: Glowing Text Effect

.glowing-text {
  font-size: 4rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #ff00de, 0 0 40px #ff00de, 0 0 50px #ff00de, 0 0 60px #ff00de, 0 0 70px #ff00de;
  animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #ff00de, 0 0 40px #ff00de, 0 0 50px #ff00de, 0 0 60px #ff00de, 0 0 70px #ff00de;
  }
  to {
    text-shadow: 0 0 20px #fff, 0 0 30px #ff6c6c, 0 0 40px #ff6c6c, 0 0 50px #ff6c6c, 0 0 60px #ff6c6c, 0 0 70px #ff6c6c, 0 0 80px #ff6c6c;
  }
}

This code creates a glowing text effect using CSS animations and text-shadow properties.

Example 2: Neon Button Effect

.neon-button {
  display: inline-block;
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
  color: #fff;
  background-color: #ff00de;
  border-radius: 5px;
  box-shadow: 0 0 10px #ff00de, 0 0 20px #ff00de, 0 0 30px #ff00de, 0 0 40px #ff00de;
  animation: neon-glow 1.5s ease-in-out infinite alternate;
}

@keyframes neon-glow {
  from {
    box-shadow: 0 0 10px #ff00de, 0 0 20px #ff00de, 0 0 30px #ff00de, 0 0 40px #ff00de;
  }
  to {
    box-shadow: 0 0 20px #ff00de,

Competitor Comparisons

46,619

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API

Pros of dayjs

  • Lightweight (< 2kB gzipped) and fast
  • Provides a similar API to Moment.js, making it easy to migrate
  • Supports a wide range of date and time operations, including parsing, formatting, and manipulation

Cons of dayjs

  • Lacks some of the advanced features and plugins available in Moment.js
  • May not be as widely adopted as Moment.js, which has a larger ecosystem

Code Comparison

dayjs:

import dayjs from 'dayjs'

const date = dayjs('2023-04-01')
console.log(date.format('YYYY-MM-DD')) // Output: 2023-04-01

magicCss:

.magic {
  --color: #7928ca;
  background: linear-gradient(45deg, #7928ca, #ff4ecd);
  background-size: 400% 400%;
  animation: gradient 10s ease infinite;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
47,953

Parse, validate, manipulate, and display dates in javascript.

Pros of moment/moment

  • Comprehensive library for date and time manipulation, with a wide range of features and utilities.
  • Extensive documentation and community support, making it easy to learn and use.
  • Supports a wide range of locales and time zones, making it suitable for international applications.

Cons of moment/moment

  • Relatively large file size, which can impact performance in some cases.
  • Dependency on the moment library can increase the overall project size and complexity.
  • The library is no longer actively maintained, and the team has recommended using alternative libraries like date-fns or Luxon.

Code Comparison

moment/moment:

const now = moment();
console.log(now.format('MMMM Do YYYY, h:mm:ss a')); // Output: "April 12th 2023, 3:30:00 PM"

const birthday = moment('1990-05-15');
console.log(birthday.fromNow()); // Output: "33 years ago"

chokcoco/magicCss:

.magic {
  background: linear-gradient(to right, #ff6b6b, #ffa500, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff);
  background-size: 200% 200%;
  animation: rainbow 10s ease infinite;
}

@keyframes rainbow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
34,434

⏳ Modern JavaScript date utility library ⌛️

Pros of date-fns/date-fns

  • Comprehensive set of date and time manipulation functions
  • Extensive documentation and community support
  • Highly performant and optimized for modern JavaScript environments

Cons of date-fns/date-fns

  • Larger bundle size compared to magicCss
  • Requires additional dependencies (e.g., Intl API polyfills) for certain features

Code Comparison

date-fns/date-fns

import { format, parseISO } from 'date-fns';

const date = parseISO('2023-04-18');
const formattedDate = format(date, 'yyyy-MM-dd');
console.log(formattedDate); // Output: '2023-04-18'

chokcoco/magicCss

.magic {
  background: linear-gradient(to right, #ff6b6b, #ffa500);
  background-size: 200% 200%;
  animation: gradient 10s ease infinite;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
144,559

JavaScript Style Guide

Pros of airbnb/javascript

  • Comprehensive and well-documented style guide for JavaScript, covering a wide range of best practices and conventions.
  • Widely adopted and used by many prominent companies and open-source projects, ensuring consistency and maintainability.
  • Actively maintained and updated to keep up with the evolving JavaScript ecosystem.

Cons of airbnb/javascript

  • The style guide may be opinionated and not align with the preferences of all developers.
  • Enforcing the style guide can add overhead and complexity to the development process, especially for smaller projects.
  • The guide may not be as flexible or customizable as some developers would prefer.

Code Comparison

airbnb/javascript:

// Use const for all of your references; avoid using var
const superPower = superPower || 'no power';

chokcoco/magicCss:

.magic {
  background: linear-gradient(to right, #ff6b6b, #ffa500);
  background-size: 200% 200%;
  animation: colorChange 10s ease infinite;
}

@keyframes colorChange {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

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

magicCss

CSS3 奇思妙想,使用 CSS3 在单个标签内实现各类图形。

除去一些需要背景衬托的图形,本项目中所有图形均为单标签图形,即使用一个标签完成整个图案。

Demo链接Description
CSS3奇思妙想CSS3奇思妙想,单标签实现各类图形
SVG奇思妙想使用 SVG or clip-path 创建的图形

由来

拜读了 《CSS Secret》 这本大作之后,有了这个项目的想法。其中带星号的图形为书中出现过的实例。

大量使用了 ::before 、::after 伪元素,transparent、border ,多重线性与径向渐变,多重内外阴影,实现了许多奇妙的图形。

很多例子参照了书中得来,也有许多我工作中实践积攒而来的。

Contact

如果有任何问题或者疑问,可以加 QQ 群:418766876 。也欢迎想讨论各种天马行空的 CSS 相关问题的小伙伴们加入。

qqqun