惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
F
Fox-IT International blog
Recorded Future
Recorded Future
T
ThreatConnect
T
The Exploit Database - CXSecurity.com
SecWiki News
SecWiki News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
T
Tenable Blog
L
LINUX DO - 最新话题
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
博客园 - 司徒正美
The Hacker News
The Hacker News
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Scott Helme
Scott Helme
博客园 - 【当耐特】
O
OpenAI News
Schneier on Security
Schneier on Security
Latest news
Latest news
S
Security @ Cisco Blogs
S
Secure Thoughts
F
Full Disclosure
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
T
Tor Project blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
小众软件
小众软件
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
N
News and Events Feed by Topic
E
Exploit-DB.com RSS Feed
J
Java Code Geeks
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Schneier on Security
Cisco Talos Blog
Cisco Talos Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
雷峰网
雷峰网

DEV Community

Polyglot Persistence in Microservices: Let the Domain Choose the Database 190 Countries, Zero API Calls: Shipping Static Data in a Chrome Extension Your AI Writes Code Fast. Here’s How to Check It Before Shipping qwen2.5-coder is too slow for Claude Code on a Mac. Here's the fix. Building Automated Text-to-Video Pipelines with AI Can Gemini Become an Offline AI Tutor? Lessons from Building Educational AI OPRIX : From a simple messaging web app to a well structured and enhanced UI messaging web app Why React + TypeScript Nullability Slowly Becomes Exhausting Why AI Agents Need a Project Layer - Part 1 Stop Hand-Editing MCP Configs: A Zero-Dependency Go CLI What I Learned Working With Microsoft, SQUAD(GTCO), and Different Tech Communities 🧠 Hermes Agent Assistant — A Modular AI Agent System with Planner, Executor & Memory Spring Boot Auto-Configuration Source Code: Nail This Interview Question The Ultimate Guide to Free AI API Keys: 6 Platforms You Need to Know Why 91% of AI Agents Fail in Production (And What the 9% Do Differently) TryHackMe | Battery | WALKTHROUGH Stop Guessing Your Regex — Test It Live in the Browser I Built FreelancEye, an Open-Source Mobile PWA for Finding Clients Beyond the Hype: My Production Playbook for Docker Swarm Top AI App Builder Platforms with Integrated Backend, Hosting & Database ECS vs EKS in 2026: An Honest Comparison from Someone Who Has Run Both in Production Hardening Your Node.js App Against Supply Chain & Remote Code Execution Attacks linux commands A Practical GEO Case: How an AI System Started Recommending Our Blog Your AI Agent Works 24/7 and Earns $0. I Built the Fix. Your AI Trading Agent Will Lose All Your Money — Here's How To Stop It Google I/O 2026: What Happens When Everything Connects? Why AI writes software but doesn’t build a good product Beyond the Hype: How Google I/O 2026 Secretly Democratized Production-Ready AI Agents with Managed Sandboxes. The Killer Assumption Test: How to Spot Doomed Product Decisions Before You Ship Stop Describing Your Bugs — Just Screenshot Them # I Built an AI Website Builder and Here's What Actually Happened Cooking an AI Campaign in 5 Minutes with Google Cloud AI APIs Your PM Retrospectives Are Lying to You How I Built a Free, Self-Hosted Pipeline That Auto-Generates Faceless YouTube Shorts TypeScript 54 to 58: The Features That Actually Matter in 2026 How to Tailor Your CV to Any Job Posting in 2026 The 7-day SaaS MVP loop: ship fast, then validate with people who actually show up 95. Fine-Tuning LLMs: Make a General Model Do Your Specific Job What Is a Frontend Developer Roadmap and Why You Need One Google shipped three Gemini "Flash" models. Picking the wrong one could 6 your AI bill Building an MCP server so Claude can query my SaaS analytics directly Google I/O 2026 and the Rise of the AI Ecosystem Your Docker Builds Are Slow Because You're Doing It Wrong (And I Built a Tool to Prove It) How do you verify GitHub contributions without trusting self-reported skills? CV vs Resume: What's the Difference and Which Do You Need? student Devs: Build AI Agents & Compete for $55K in Prizes 🚀 How to Write a Cover Letter That Actually Gets You Interviews Battle-Tested: What Getting Hacked Taught Me About Web & Cyber Security Unda folders za kuandika code >> mkdir src >> cd src >> mkdir controllers database routes services utils >> cd .. Directory: C:\Users\mwaki\microfinance-system Mode LastWriteTime Length Name Code Coverage .NET AI slop debt" is technical debt on fast forward. Nobody's ready. Multi-Head Latent Attention (MLA) Memoria - A Local AI Reading Companion Powered by Gemma 4 Stop Trusting Your Accuracy Score: A Practical Guide to Evaluating Logistic Regression Models Serious Question: Is the Developer Job Actually in Risk Due to AI? published: true tags: #discuss #career #ai #help rav2d: We ported an AV2 video decoder from C to Rust — here's why Your New Domain's First Week of GA4 Is a Lie: 4 Days of Raw Data from a Launch Gemma Guide - Real-Time Spatial Awareness for Blind Users From YAML to AI Agents: Building Smarter DevOps Pipelines with MCP A Field Guide to Human–AI Relations (For the Newly Bewildered Mortal) The AI Agent That Learns While It Works — A Complete Guide to Hermes Agent Inviting collaborators to work on ArchScope ArchScope is an interactive web-based tool that lets you design, visualize, and test system architectures with real-time performance simulations. Github - ArchScope is an interactive web-based tool that lets you Gemma 4: Google's Open-Weight AI Is a Game Changer for Developers Confessions of a Git Beginner: Why the Terminal Stopped Scaring Me Docker 容器化实战:从零到生产部署 🚀 I Built a Full Stack Miro Clone with Real-Time Collaboration using Next.js Building an African Economic Data Pipeline with Python, DuckDB & World Bank API llms.txt vs robots.txt vs ai.txt: The Developer's Cheat Sheet Intigriti Challenge 0526 Writeup Business Logic Flaws: How Attackers Skip Steps in Your App to Get What They Should Never Have Why Vibe Coders Need Boilerplates to Save Time, Tokens, and Build More Secure SaaS Projects Idle Cloud Cost Is the New Egress Cost Quark's Outlines: Python Traceback Objects Ghost in the Stack (Part 1): Why uninitialized variables remember old data Building a High-Performance Local Chess Assistant Extension with WebAssembly Stockfish and Manifest V3 Breaking the Trade-off Between Self-Custody and Intelligent Automation on the Stellar Network I Open-Sourced a Practical Fullstack Interview Preparation Repository (React + Node + System Design) 🚀 How I Started Coding as a Student (Beginner-Friendly Guide) WordPress vs. Ghost: Why Automated Bot Attacks Are Making us think much I tested 4 AI agent-governance tools against an open spec - here's the matrix zkML Inference Proof: What the Receipt Proves, and What the Model Still Does Not I Scored 1000/1000 on AWS Certified AI Practitioner (AIF-C01) Here's Every Resource I Used Go - Struct and Interface Handling JSON Requests in Go Storing Kamal secrets in AWS Secrets Manager and deploying to a cheap Hetzner VPS How I Caught and Fixed an N+1 Query in My Django REST API I got tired of paying $10/month to remove image backgrounds – so I built it for free How to Start Coding as a Student: A Complete Beginner’s Guide 🚀 Storing Kamal secrets in AWS Secrets Manager and deploying to a cheap Hetzner VPS What Are Buffers? Build AI Agents with Hot Dev The Client Onboarding Checklist That Prevents 90% of Project Problems Scalable Treasure Hunts Are a Myth, But We Almost Made One Gemini 3.5 Flash Has a 1M Token Context Window. Here's What You Can Actually Build With It. I built a ultra-polished developer portfolio template using React & Tailwind v4 (with zero-JSX configuration) Gemini CLI Is Dead. Here's the Better Thing That Replaced It Post-quantum cryptography for embedded and IoT: secure boot, TLS and OTA Understanding Optimistic Preloading in Modern Applications Nobody Wants to Read Your Code (And You Don't Want to Read Theirs)
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!