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

推荐订阅源

美团技术团队
J
Java Code Geeks
有赞技术团队
有赞技术团队
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
G
Google Developers Blog
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
腾讯CDC
V
Visual Studio Blog
博客园 - 【当耐特】
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
L
LangChain Blog

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
Responsive Toolbars and Navbars - Done Right!
Artur Marczy · 2026-04-29 · via DEV Community

Look ma, no media queries!

Responsive design is basically solved nowadays, right? We've been doing media queries for over a decade, we have @container queries now, and we have cool tricks like CSS Grid's repeat(auto-fit, minmax()).
All this works pretty well, especially when things are static. But if you are dealing with dynamic content, things can still get less than perfect 😅. It's especially easy to trip over toolbars, even for the pros:

Common failures:

site with dynamic navbar goes wrong 🥺
blog.google at 1025px 😥 Google Blog navbar overflowing around 1025px
cloudflare.com English is fine, but German or Polish not so much 😭 Cloudflare toolbar fitting in English Cloudflare toolbar getting tight in German Cloudflare toolbar getting tight in Polish
OpenAI docs below 820px wide are not even dynamic, and still break 🤮 OpenAI docs navbar overflowing below 820px

This happens because you can't really solve this when there is dynamic content using pure CSS, where you have to rely on fixed pixel breakpoints.
To solve it correctly and robustly, you're gonna need some JS, or smart tools 🤓

The way to fix all of those is to detect when those navbars overflow. It's actually not that difficult, and a competent AI agent can whip up some HTML+JS or React code.

OverflowGuard to the rescue 🛟

And you can stop here and call it a day, I guess 🤷‍♂️. But we can make this even easier by using a smart tool: OverflowGuard.
It does exactly what it says on the tin 🏷️: it detects overflow and lets you swap in alternative styles or content.
It has two flavors:

Navbars are just the most common example. Other use cases you might easily find:

Removing labels from buttons

That’s a useful way to keep a toolbar compact when horizontal space gets tight. Toolbars with buttons are notoriously dynamic (translations, permissions, other context), so it's sometimes impossible to find good hard-coded breakpoints.
Toolbar buttons collapsing from labels to icons
Check out a HTML example, and a React example

"Read more..."

Let’s not limit ourselves to the horizontal. OverflowGuard works perfectly well in the vertical ↕️ direction. Here's something you might want to do: set a max height on a box and show a "read more" button if the content inside overflows.
Again, this is easily doable in HTML or React.
Read more button appearing when content overflows vertically

A "greedy nav" 🧭 🍽️

Leaving the best for last: a robust pattern for dynamic navbars called "greedy nav", which you can find, for example, on another Google page that actually works correctly 😉.
You can nest OverflowGuard, so it's quite easy to use it to build a greedy nav, especially in React.
It's doable in raw HTML too, if you're OK with all the extra nesting 😅 (still accessible, notably), or by adding some extra JS.

Give it a go 🏃

Once you have OverflowGuard in your toolbag, I am sure it will unlock some cool tricks 🪄 you never thought could be so easy to implement. Also mention it to your designers 🎨. They often work in fixed breakpoints 🙄, but with this capability they can lean into more fluid and content-driven design.

Ways to get started

bun add overflow-guard-react

Enter fullscreen mode Exit fullscreen mode

bun add overflow-guard-html

Enter fullscreen mode Exit fullscreen mode

Or drop the custom element straight into a no-build page:

<script src="https://cdn.jsdelivr.net/npm/overflow-guard-html@0"></script>

Enter fullscreen mode Exit fullscreen mode

If you want your AI agent to know how to use the library, install the package-specific skill too:

npx skills add https://github.com/arturmarc/overflow-guard/tree/main/packages/overflow-guard-react --skill overflow-guard-react

Enter fullscreen mode Exit fullscreen mode

npx skills add https://github.com/arturmarc/overflow-guard/tree/main/packages/overflow-guard-html --skill overflow-guard-html

Enter fullscreen mode Exit fullscreen mode