Pure.css Counter Example - Pure-css Typing CST Test
Loading…
Pure.css Counter Example — Pure-css Code
Demonstrates a simple counter layout using Pure.css classes and minimal JavaScript for interactivity.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/purecss@2.1.0/build/pure-min.css">
<title>Pure.css Counter</title>
</head>
<body class="pure-g pure-u-1 tc pa4">
<h2 class="f3 mb3">Counter: <span id="count">0</span></h2>
<div class="pure-button-group mb3">
<button id="increment" class="pure-button pure-button-primary">+</button>
<button id="decrement" class="pure-button pure-button-error">-</button>
<button id="reset" class="pure-button">Reset</button>
</div>
<button id="theme-btn" class="pure-button pure-button-warning">Switch Theme</button>
<script>
let count = 0;
let isDark = false;
const countEl = document.getElementById('count');
const body = document.body;
document.getElementById('increment').onclick = () => { count++; countEl.textContent = count; };
document.getElementById('decrement').onclick = () => { count--; countEl.textContent = count; };
document.getElementById('reset').onclick = () => { count = 0; countEl.textContent = count; };
document.getElementById('theme-btn').onclick = () => {
isDark = !isDark;
body.classList.toggle('bg-dark', isDark);
body.classList.toggle('white', isDark);
body.classList.toggle('bg-light', !isDark);
body.classList.toggle('black', !isDark);
};
</script>
<style>
.bg-dark { background-color: #222; }
.bg-light { background-color: #fff; }
.white { color: #fff; }
.black { color: #000; }
</style>
</body>
</html>Pure-css Language Guide
Pure CSS is a minimal, responsive CSS framework by Yahoo that provides a lightweight grid system and basic UI components without JavaScript. It's designed for speed, simplicity, and performance.
Primary Use Cases
- ▸Landing pages and marketing websites
- ▸Lightweight responsive websites
- ▸Rapid prototyping without JS
- ▸Email templates or static sites
- ▸Web apps using separate JS frameworks
Notable Features
- ▸Minimal, lightweight CSS framework
- ▸Responsive mobile-first grid system
- ▸Prebuilt modules: buttons, forms, tables, menus
- ▸Cross-browser compatible
- ▸No JavaScript dependencies
Origin & Creator
Created by Yahoo in 2008, Pure CSS was designed to provide a simple, fast, and responsive CSS toolkit for building websites without the overhead of large frameworks.
Industrial Note
Perfect for small to medium projects where minimal CSS, fast load times, and responsive layouts are required, especially when no JavaScript components are needed.
Quick Explain
- ▸Pure CSS offers a mobile-first, responsive grid and simple UI modules.
- ▸It has no JavaScript dependencies, making it extremely lightweight.
- ▸Ideal for developers who want a minimal CSS foundation without heavy frameworks.
Core Features
- ▸Grid system with 5-column layouts
- ▸UI modules: buttons, tables, forms, menus, lists
- ▸Responsive breakpoints for mobile-first design
- ▸Simple typography and form styling
- ▸Easy to customize and extend
Learning Path
- ▸Learn Pure CSS grid system
- ▸Explore modules: buttons, forms, tables, menus
- ▸Practice responsive design
- ▸Integrate with JS frameworks if needed
- ▸Customize with CSS overrides
Practical Examples
- ▸Landing pages
- ▸Marketing websites
- ▸Email templates
- ▸Lightweight web apps
- ▸Static sites with responsive grids
Comparisons
- ▸No JS unlike Metro 4 or Semantic UI
- ▸Minimal, lightweight vs. Bootstrap
- ▸Utility-class light vs. Tailwind
- ▸Simple responsive grid
- ▸Easy to integrate and extend
Strengths
- ▸Extremely lightweight and fast
- ▸No JS or dependencies
- ▸Responsive and mobile-first
- ▸Easy to learn and implement
- ▸Flexible to integrate with any JS framework
Limitations
- ▸No JavaScript components
- ▸Limited prebuilt UI compared to Bootstrap or Metro 4
- ▸Requires custom work for advanced UI interactions
- ▸Smaller ecosystem and community
- ▸Basic styling only, not opinionated visually
When NOT to Use
- ▸Projects needing prebuilt JS components
- ▸Complex dashboards requiring interactivity
- ▸Design-heavy websites without custom CSS
- ▸Projects requiring large community support
- ▸Enterprise apps needing advanced widgets
Cheat Sheet
- ▸`.pure-g` - grid container
- ▸`.pure-u-1-2` - half-width column
- ▸`.pure-button` - button
- ▸`.pure-table` - table
- ▸`.pure-menu` - menu
FAQ
- ▸Is Pure CSS still maintained?
- ▸Yes, minimal maintenance, stable framework.
- ▸Can I use Pure CSS with JS frameworks?
- ▸Yes, completely compatible.
- ▸Does it support responsive design?
- ▸Yes, via mobile-first grids.
- ▸Is it beginner-friendly?
- ▸Yes, simple and minimal.
- ▸Can I customize the styling?
- ▸Yes, through additional CSS overrides.
30-Day Skill Plan
- ▸Week 1: Grid system basics
- ▸Week 2: Buttons and forms
- ▸Week 3: Tables and menus
- ▸Week 4: Responsive layouts
- ▸Week 5: Custom CSS and integration
Final Summary
- ▸Pure CSS is a minimal, responsive CSS-only framework.
- ▸Provides grids, forms, buttons, tables, and menus.
- ▸Extremely lightweight and fast.
- ▸No JS dependencies make it ideal for simple projects.
- ▸Best for minimalistic, static, or prototyped web apps.
Project Structure
- ▸index.html - main markup
- ▸css/ - custom overrides
- ▸assets/ - images, fonts
- ▸node_modules/ - npm dependencies if used
- ▸No JS folder required
Monetization
- ▸Offer lightweight Pure CSS templates
- ▸Consult on minimal web app development
- ▸Develop responsive email templates
- ▸Create CSS kits for prototyping
- ▸Build static sites for clients
Productivity Tips
- ▸Use only required CSS modules
- ▸Leverage responsive grid for layouts
- ▸Create reusable CSS overrides
- ▸Avoid unnecessary styling
- ▸Minify CSS for faster loading
Basic Concepts
- ▸Grid: `.pure-g`, `.pure-u-1`, `.pure-u-md-1-2`
- ▸Buttons: `.pure-button`, `.pure-button-primary`
- ▸Forms: `.pure-form`, `.pure-input-1`, `.pure-control-group`
- ▸Tables: `.pure-table`, `.pure-table-bordered`
- ▸Menus: `.pure-menu`, `.pure-menu-horizontal`