Container Queries
01Responsive card that changes layout based on container size
🔄 Drag the right edge to resize the container and watch the layout adapt!
John Doe
Frontend Developer
/* Container Queries Demo */
.resizable-container {
container-type: inline-size;
container-name: demo-container;
resize: horizontal;
overflow: auto;
}
/* Small container (< 350px) */
@container demo-container (max-width: 349px) {
.card-header-demo {
flex-direction: column;
text-align: center;
}
.card-actions {
flex-direction: column;
}
}
/* Medium container (350px - 549px) */
@container demo-container (min-width: 350px) and (max-width: 549px) {
.card-header-demo {
flex-direction: row;
}
}
/* Large container (550px+) */
@container demo-container (min-width: 550px) {
.responsive-card {
display: grid;
grid-template-columns: auto 1fr auto;
grid-template-areas:
"avatar info actions"
"content content content";
}
}
CSS Tooltips
02Multiple 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
/* CSS Tooltips - Advanced Examples */
/* Base Tooltip */
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
}
.tooltip::after {
content: attr(data-tooltip);
position: absolute;
background: linear-gradient(135deg, #0a0a0a, #1a1a2e);
color: #ffffff;
padding: 0.75rem 1rem;
border-radius: 6px;
font-size: 0.8rem;
opacity: 0;
pointer-events: none;
transition: all 0.3s ease;
border: 1px solid #00ffff;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
/* Top Position */
.tooltip-top::after {
bottom: calc(100% + 8px);
left: 50%;
transform: translateX(-50%) translateY(10px);
}
.tooltip-top:hover::after {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
/* Delayed Tooltip */
.tooltip-delay::after {
transition-delay: 0.5s;
}
/* Bounce Animation */
.tooltip-bounce:hover::after {
animation: tooltipBounce 0.6s ease;
}
@keyframes tooltipBounce {
0%, 20%, 53%, 80%, 100% {
transform: translateX(-50%) translateY(0);
}
40%, 43% {
transform: translateX(-50%) translateY(-10px);
}
}
Magic Hover Effects
03Collection 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
/* Magic Hover Effects - Advanced Examples */
/* Liquid Morphing Effect */
.liquid-btn {
background: linear-gradient(45deg, #00ffff, #8b5cf6);
border-radius: 50px;
transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1);
}
.liquid-btn::before {
content: '';
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
background: linear-gradient(45deg, #ff0080, #00ff41);
border-radius: 50px;
opacity: 0;
transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1);
z-index: -1;
}
.liquid-btn:hover {
transform: scale(1.1) rotate(2deg);
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 255, 255, 0.4);
}
.liquid-btn:hover::before {
opacity: 1;
transform: scale(1.2) rotate(-2deg);
border-radius: 30px;
}
/* 3D Flip Effect */
.flip-btn {
perspective: 1000px;
transform-style: preserve-3d;
transition: transform 0.6s ease;
}
.flip-btn:hover {
transform: rotateY(180deg);
}
/* Glitch Effect */
.glitch-btn:hover {
animation: glitchMain 0.3s ease-in-out infinite;
}
@keyframes glitchMain {
0%, 100% { transform: translate(0); }
20% { transform: translate(-1px, 1px); }
40% { transform: translate(1px, -1px); }
60% { transform: translate(-1px, -1px); }
80% { transform: translate(1px, 1px); }
}
Fluid Typography
04Text that scales smoothly with viewport
📏 Drag the slider to simulate different viewport sizes and see text scale smoothly!
clamp() Function Examples
Heading Text
Body text that scales proportionally with the viewport width for optimal reading experience.
/* Fluid Typography - Advanced Examples */
/* Fluid Heading */
.fluid-heading {
font-size: clamp(1.5rem, 5vw, 4rem);
font-weight: 900;
line-height: 1.1;
text-transform: uppercase;
letter-spacing: 0.05em;
}
/* Fluid Subheading */
.fluid-subheading {
font-size: clamp(1rem, 3vw, 2rem);
font-weight: 600;
line-height: 1.2;
}
/* Fluid Body Text */
.fluid-body {
font-size: clamp(0.9rem, 2vw, 1.2rem);
line-height: clamp(1.4, 1.5vw, 1.6);
max-width: 600px;
}
/* Viewport Simulator */
.simulated-viewport {
width: clamp(320px, 100%, 800px);
transition: all 0.3s ease;
border: 2px solid #00ff41;
padding: 2rem;
}
/* Alternative Approaches */
.calc-approach {
font-size: calc(1rem + 2vw);
/* Note: Use clamp() for better control */
}
.media-query-approach {
font-size: 1rem;
}
@media (min-width: 768px) {
.media-query-approach {
font-size: 1.25rem;
}
}
@media (min-width: 1280px) {
.media-query-approach {
font-size: 1.5rem;
}
}
Scroll Snap
05Horizontal scrolling gallery with snap points
📱 Scroll horizontally or use navigation buttons to see smooth snap points!
Interactive Gallery
Scroll Snap Start
Items snap to the start of the container for precise alignment.
Smooth Scrolling
CSS scroll-behavior: smooth creates fluid transitions between items.
Mandatory Snap
scroll-snap-type: x mandatory ensures items always snap to position.
Custom Scrollbar
Styled scrollbars with neon colors match the cyberpunk theme.
Responsive Design
Gallery adapts to different screen sizes while maintaining snap behavior.
Accessibility
Keyboard navigation and focus management for inclusive design.
Mandatory Snap
Always snaps to the nearest snap point
Proximity Snap
Snaps only when close to a snap point
/* Scroll Snap - Advanced Gallery */
/* Snap Container */
.snap-container {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
gap: 1rem;
padding: 1rem 0;
}
/* Snap Items */
.snap-item {
flex: 0 0 280px;
height: 200px;
scroll-snap-align: start;
scroll-snap-stop: always;
border-radius: 12px;
background: linear-gradient(135deg, #1a1a2e, #16213e);
transition: all 0.3s ease;
}
.snap-item:hover {
transform: translateY(-4px);
box-shadow: 0 8px 25px rgba(255, 0, 128, 0.2);
}
/* Custom Scrollbar */
.snap-container::-webkit-scrollbar {
height: 8px;
}
.snap-container::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
}
.snap-container::-webkit-scrollbar-thumb {
background: #ff0080;
border-radius: 4px;
}
/* Snap Types */
.mandatory-snap {
scroll-snap-type: x mandatory;
}
.proximity-snap {
scroll-snap-type: x proximity;
}
/* Navigation Buttons */
.nav-btn {
background: transparent;
border: 1px solid #ff0080;
color: #ff0080;
width: 36px;
height: 36px;
border-radius: 50%;
cursor: pointer;
transition: all 0.3s ease;
}
.nav-btn:hover:not(:disabled) {
background: #ff0080;
color: #0a0a0a;
box-shadow: 0 0 15px rgba(255, 0, 128, 0.4);
}
Dynamic Themes
06Theme 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
/* Dynamic Themes Example */
:root {
--bg-color: #ffffff;
--text-color: #000000;
}
[data-theme="dark"] {
--bg-color: #1a1a1a;
--text-color: #ffffff;
}
[data-theme="neon"] {
--bg-color: #0a0a0a;
--text-color: #00ffff;
}
body {
background: var(--bg-color);
color: var(--text-color);
transition: all 0.3s ease;
}
CSS Grid Magic
07Complex grid layout that adapts responsively
/* CSS Grid Magic Example */
.grid-container {
display: grid;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
grid-template-rows: auto 1fr auto;
grid-template-columns: 200px 1fr;
min-height: 100vh;
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }
Physics Animations
08Collection of natural motion animations
🎯 Hover over the buttons to see physics-based animations!
Floating Particles
/* Physics Animations Example */
@keyframes bounce {
0%, 20%, 53%, 80%, 100% {
transform: translate3d(0,0,0);
}
40%, 43% {
transform: translate3d(0, -30px, 0);
}
70% {
transform: translate3d(0, -15px, 0);
}
90% {
transform: translate3d(0, -4px, 0);
}
}
.bounce {
animation: bounce 1s ease-in-out;
}
Advanced Selectors
09Form with smart validation styling
📝 Fill out the form to see advanced selectors in action!
/* Advanced Selectors Example */
/* Style form when it has valid inputs */
form:has(input:valid) {
border-color: green;
}
/* Style form when it has invalid inputs */
form:has(input:invalid) {
border-color: red;
}
/* Target elements that don't have a specific class */
div:not(.special) {
opacity: 0.5;
}
/* Modern selector combinations */
input:is(:focus, :hover) {
outline: 2px solid blue;
}
CSS Houdini
10Custom paint worklet with adjustable properties
🎨 Adjust the controls to see CSS Houdini concepts in action!
⚠️ CSS Houdini has limited browser support. This demo simulates the concepts using standard CSS.
/* CSS Houdini Example */
/* Register custom property */
@property --gradient-angle {
syntax: '';
initial-value: 0deg;
inherits: false;
}
/* Use custom paint worklet */
.houdini-element {
background: paint(custom-gradient);
--gradient-angle: 45deg;
transition: --gradient-angle 0.3s ease;
}
.houdini-element:hover {
--gradient-angle: 180deg;
}