CSS Magic Tricks

10 Techniques That Will Blow Your Mind

Container Queries

01

Responsive card that changes layout based on container size

🔄 Drag the right edge to resize the container and watch the layout adapt!

400px
JD

John Doe

Frontend Developer

This card layout changes based on the container size using CSS Container Queries. Try resizing to see different layouts!
Small
Medium
Large

CSS Tooltips

02

Multiple tooltip examples with different positions

🖱️ Hover over the buttons to see different tooltip positions and effects!

Positions

Basic tooltip positioning

Timing

Different delay timings

Animations

Special animation effects

Effects

Visual enhancements

Magic Hover Effects

03

Collection of advanced button hover effects

🎨 Hover over the buttons to see amazing transformation effects!

Morphing

Shape and form transformations

3D Transform

Three-dimensional animations

Special FX

Unique visual effects

Fluid Typography

04

Text that scales smoothly with viewport

📏 Drag the slider to simulate different viewport sizes and see text scale smoothly!

Viewport Simulator

768px

Fluid Typography

Scales Beautifully

This text uses clamp() to scale smoothly between minimum and maximum sizes. The font-size adapts to the viewport width while maintaining readability across all device sizes.

clamp() Function Examples

clamp(1.2rem, 4vw, 2.5rem)

Heading Text

clamp(0.8rem, 2vw, 1.1rem)

Body text that scales proportionally with the viewport width for optimal reading experience.

clamp(0.7rem, 1.5vw, 0.9rem)
Caption or small text

Scroll Snap

05

Horizontal scrolling gallery with snap points

📱 Scroll horizontally or use navigation buttons to see smooth snap points!

Mandatory Snap

Always snaps to the nearest snap point

A
B
C
D
E
Proximity Snap

Snaps only when close to a snap point

A
B
C
D
E

Dynamic Themes

06

Theme toggle between light/dark/neon modes

🎨 Click theme buttons to see CSS custom properties change in real-time!

Dynamic Themes

CSS Custom Properties

This demonstration shows how CSS custom properties (variables) can be used to create dynamic theme systems. Each theme updates multiple variables simultaneously, creating cohesive design changes across all elements.

CSS Variables in Action

--theme-bg
rgba(0, 0, 0, 0.8)
--theme-text
#ffffff
--theme-accent
#8b5cf6
--theme-secondary
#00ffff

CSS Grid Magic

07

Complex grid layout that adapts responsively

Header
Sidebar
Main Content
Aside

Physics Animations

08

Collection of natural motion animations

🎯 Hover over the buttons to see physics-based animations!

Floating Particles

Advanced Selectors

09

Form with smart validation styling

📝 Fill out the form to see advanced selectors in action!

:has() Selector
form:has(input:valid)
Styles form when it contains valid inputs
:is() Selector
input:is(:focus, :hover)
Matches elements in focus OR hover state
:not() Selector
input:not(:placeholder-shown)
Targets inputs that have user content

CSS Houdini

10

Custom paint worklet with adjustable properties

🎨 Adjust the controls to see CSS Houdini concepts in action!

CSS Houdini Demo
45°
80%
🎨
Paint API
Custom rendering with JavaScript
⚙️
Properties API
Register custom CSS properties
🔄
Animation API
Control animation timeline

⚠️ CSS Houdini has limited browser support. This demo simulates the concepts using standard CSS.