인셔셔RSS 관심 있는 블로그, 뉴스, 기술 정보를 효율적으로 추적하고 읽으세요
원문 읽기 InertiaRSS에서 열기

추천 피드

F
Full Disclosure
月光博客
月光博客
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
PCI Perspectives
PCI Perspectives
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Latest news
Latest news
P
Palo Alto Networks Blog
Blog — PlanetScale
Blog — PlanetScale
Cyberwarzone
Cyberwarzone
P
Privacy International News Feed
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
S
Securelist
H
Hackread – Cybersecurity News, Data Breaches, AI and More
NISL@THU
NISL@THU
GbyAI
GbyAI
H
Hacker News: Front Page
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
U
Unit 42
T
The Blog of Author Tim Ferriss
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cloudbric
Cloudbric
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
L
LINUX DO - 最新话题
The Hacker News
The Hacker News
WordPress大学
WordPress大学
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
T
Threatpost
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
L
LINUX DO - 热门话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
K
Kaspersky official blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Mathematical Functions in CSS: clamp, min, max and How They Simplify Responsiveness
Nick Benksim · 2026-05-23 · via DEV Community

Nick Benksim

The Math Cure for Your Layout Headaches

Grab a cup of coffee and let's have a real talk about responsive design. We have all been there: you build a gorgeous layout, and it looks absolutely crisp on your 27-inch 5K monitor. But the moment you test it on an iPhone SE or a giant ultra-wide screen, the design completely falls apart. Headlines either stretch into monstrous proportions or shrink down to microscopic text. Margins blow up, and components start overlapping in the worst ways possible.

Making layouts look perfect on every device used to mean writing endless media queries. But today, we have smarter tools in our CSS arsenal that do the heavy lifting for us: the mathematical functions clamp(), min(), and max(). Let's look at how they can save your sanity and clean up your stylesheets.

How We Suffered Before

Remember the dark ages of responsive web design? To make a font scale dynamically with the viewport, we relied on viewport units like vw. It sounded great on paper: just set font-size: 5vw and watch it scale! But in reality, on tiny screens, your 5vw text shrunk to an unreadable 4px, and on massive screens, it became a giant 120px headline.

To stop this madness, we had to resort to two painful workarounds:

  • Writing a dozen @media rules at different breakpoints to manually override the font sizes and paddings.
  • Using mind-boggling, unreadable CSS formulas like calc(16px + (24 - 16) * ((100vw - 320px) / (1200 - 320))).

If looking at that formula gives you PTSD, you are not alone. It was unmaintainable, prone to typos, and felt like a hack. Just like we used to struggle with nested layouts before CSS Subgrid solved our grid alignment nightmares, managing responsive typography and spacing was an absolute chore.

The Modern Way in 2026

Today, the mathematical trinity of CSS—min(), max(), and clamp()—is fully supported, incredibly robust, and ready to replace hundreds of lines of media queries. Here is how they work in simple terms:

1. max(value1, value2, ...)

The max() function compares the values you give it and chooses the largest one. Think of it as setting a minimum floor for a property. For example, width: max(50%, 300px) means: "Take up half the screen, but never shrink below 300px."

2. min(value1, value2, ...)

The min() function does the exact opposite: it compares the values and selects the smallest one. This acts as a maximum ceiling. For instance, width: min(80%, 1200px) means: "Take up 80% of the screen, but freeze once you hit 1200px."

3. clamp(minimum, preferred, maximum)

This is the absolute holy grail of modern responsive design. clamp() takes three arguments: a lower bound, a fluid/preferred value, and an upper bound. It keeps the preferred value strictly within the minimum and maximum range. It is the ultimate way to handle fluid typography and dynamic spacing without ever writing a media query.

When you combine these math functions with cutting-edge layout systems like CSS Container Queries, you get components that are fully fluid, modular, and context-aware.

Ready-to-Use Code Snippet

Let's look at a practical, real-world example. Here is a clean, modern card component that uses CSS math functions to fluidly scale its typography, inner padding, and overall width without a single breakpoint rule.

/* A fully responsive, modern card layout */
.responsive-card {
  /* Dynamic width: takes up 90% of screen but caps at 600px */
  width: min(90%, 600px);
  
  /* Fluid padding: scales between 1rem and 2.5rem based on screen width */
  padding: clamp(1rem, 4vw, 2.5rem);
  
  background-color: #1e1e24;
  color: #f5f5f7;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin: 2rem auto;
}

.card-title {
  /* Fluid typography: scales between 1.5rem and 3rem based on viewport */
  font-size: clamp(1.5rem, 5vw, 3rem);
  line-height: 1.2;
  margin-bottom: 1rem;
}

.card-text {
  /* Smart text sizing that scales but stays readable */
  font-size: clamp(1rem, 1rem + 1vw, 1.25rem);
  line-height: 1.6;
  opacity: 0.9;
}

Common Beginner Mistakes

While CSS math functions look like magic, there are two classic traps that developers often fall into:

The "Static Value" Trap: Writing something like clamp(1rem, 2rem, 3rem). If your middle (preferred) value is static, the function has nothing to calculate dynamically! The browser will look at 2rem, see that it never changes, and simply lock the element at 2rem. Your middle value must always contain a dynamic unit (like vw, vh, or percentages).

The Accessibility Trap: Using pure viewport units (like 5vw) as the preferred value in clamp() for text. If a user zooms in using their browser settings, viewport units do not scale with the zoom. To keep your website accessible and compliant with WCAG guidelines, always mix viewport units with relative units (like rem or em) inside your math functions. Writing clamp(1.2rem, 1rem + 2vw, 2.5rem) ensures that the font scales beautifully with the screen size while still honoring user zoom preferences.

🔥 We publish more advanced CSS tricks, ready-to-use snippets, and tutorials in our Telegram channel. Subscribe so you don't miss out!