CSS has gone too far (deep dive on Minecraft in 100% CSS)

Introduction & CSS Power 00:00

  • CSS capabilities have expanded significantly over the years, now allowing everything from basic animations to scroll smoothing, scroll snapping, sticky elements, and even 3D transformations.
  • The video introduces the concept of building complex applications, like a game engine, with just CSS and demonstrates "CSS Minecraft"—a Minecraft clone implemented entirely in CSS without JavaScript.

Sponsor Segment - Savala 01:17

  • The sponsor, Savala, is introduced as a solution for developers overwhelmed by infrastructure choices.
  • Savala offers one-click deployment templates for a variety of frameworks and services, handling multi-cloud setup, CDN, and DDoS protection with ease.
  • A $50 free credit is mentioned for trying the service.

CSS Minecraft Deep Dive 03:16

  • CSS Minecraft was created by Benjamin Aster, whose site hosts various creative browser projects.
  • The project is open source, using 480 lines of CSS and 46,000 lines of HTML, primarily relying on input elements for state management.
  • The key mechanism employs radio inputs and labels—radio elements encode the game's state, and CSS selectors update visuals based on the selected (checked) state.
  • Every cube in the game grid has eight radio inputs representing possible block types, and labels are used for each face of every cube.
  • The lack of JavaScript means interactions rely on toggling radio buttons to trigger CSS styling changes.
  • 3D rotation and movement are achieved using CSS animations that start and stop based on input state; for example, holding a control pauses or resumes an animation.

State Management and Animation 05:44

  • The template approach allows encoding thousands of possible cube states, enabling complex UI logic.
  • Animations work by setting the animation state in CSS to "running" or "paused" based on user interaction.
  • Although there isn't traditional drag interaction, CSS still enables convincing 3D movement.

PowerPoint Turing Machine Sidebar 06:45

  • Reference is made to another engineering feat: creating a Turing-complete machine in PowerPoint using only animations and punch cards.
  • Demonstrates that with sufficient state control, even presentation apps can simulate arbitrary computation.

Mechanism and Exploration of CSS Minecraft 09:27

  • The SCSS source is discussed, showing how variables and loops are used to generate readable and maintainable code, which compiles into large CSS and HTML files.
  • Block selection, animation, and block placement mechanics rely entirely on CSS to manage appearance and logic.
  • The rendering uses pixelated image rendering for authentic pixel art appearance in the browser—even in 3D mode.
  • Various CSS techniques are used to simulate brightness and lighting for different block faces.

CSS 3D Transformations 15:29

  • By switching off "preserve-3D" or changing the perspective, the rendering mode shifts between flat and isometric, highlighting CSS's flexibility.
  • All directional controls and camera changes are done by nesting divs, with state referenced via parent elements.
  • Demonstrations in CodePen show how perspective, rotation, and transformation properties work on simple elements, with purely CSS-driven interaction and animation.

Reflection and Future Potential 18:12

  • The host expresses amazement at how CSS now supports true 3D rendering and animation, rivaling the capabilities of graphics frameworks.
  • Concludes that tastefully used 3D CSS can significantly enhance user experiences and visual engagement in web development, without the need for JavaScript.
  • Encourages viewers to experiment creatively with advanced CSS features.