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

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
M
MIT News - Artificial intelligence
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
有赞技术团队
有赞技术团队
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
美团技术团队
F
Fortinet All Blogs
I
Intezer
IT之家
IT之家
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
P
Palo Alto Networks Blog
S
Securelist
L
LINUX DO - 热门话题
Security Archives - TechRepublic
Security Archives - TechRepublic
N
Netflix TechBlog - Medium
TaoSecurity Blog
TaoSecurity Blog
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Project Zero
Project Zero
U
Unit 42
博客园_首页
博客园 - 司徒正美
S
Security Affairs
V
V2EX
T
Threatpost
T
Tailwind CSS Blog
GbyAI
GbyAI
O
OpenAI News
K
Kaspersky official blog
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
H
Hacker News: Front Page
V2EX - 技术
V2EX - 技术
Security Latest
Security Latest

Red Blob Games: latest blog posts

Red Blob Games: Academic citations Red Blob Games: Highlighting interactive code blocks Red Blob Games: Optimizing page size Red Blob Games: Writing a guide to SDF fonts Red Blob Games: URLs with trailing punctuation Red Blob Games: What I did in 2025 Red Blob Games: Goodbye Sass Goodbye Sass Red Blob Games: RotMG map seeds Red Blob Games: Mapgen4 Mapgen4's use of WebGL2 Red Blob Games: Mapgen4 river shader Red Blob Games: Mapgen4 renderer Red Blob Games: Harnessing ChatGPT hallucinations Red Blob Games: Let Let's write a search engine, part 2 of 2 Red Blob Games: Let Let's write a search engine, part 1 of 2 Red Blob Games: Hexagon conversions Red Blob Games: Mapgen4 trade routes Red Blob Games: De-optimizing mapgen4 Red Blob Games: Hexagon spiral coordinates Red Blob Games: Thoughts on Flash Red Blob Games: What I did in 2024 Red Blob Games: Hexagon page animations Red Blob Games: SDF Halos SDF Halos Red Blob Games: SDF headless tests, part 2 Red Blob Games: SDF headless tests, part 1 Red Blob Games: SDF curved text SDF curved text Red Blob Games: SDF combining distance fields Red Blob Games: SDF antialiasing Red Blob Games: SDF letter spacing Red Blob Games: SDF font outlines Red Blob Games: Labels on Maps Red Blob Games: Font Distortion Red Blob Games: Work in progress: heuristics Work in progress: heuristics Red Blob Games: Flow field pathfinding Red Blob Games: Draggable examples Red Blob Games: Testing font code Red Blob Games: Text effects Red Blob Games: Distance field effects Red Blob Games: Signed Distance Field Fonts Red Blob Games: New Blog for 2024
Red Blob Games: Responsive design calculator
2026-07-12 · via Red Blob Games: latest blog posts

A few weeks ago I got distracted when I discovered — to my horror — that occasionally the font size on my site was 1.24924375rem instead of the desired 1.25rem. Of course nobody would notice this. But I was annoyed with myself and wanted to figure out why.

My site is very old. When I started my site, people used desktop computers, mostly with 640✕480 or 800✕600 monitors. I designed my content to have a width of 450px so that there was space for browser sidebars, scrollbars, toolbars, etc. As resolution increased, I designed newer content to be 600px wide.

Over the years, monitor resolutions kept increasing, and then shrank when we got web browsers in cell phones and tablets. My site didn’t take that into account. I decided to study how other web sites handled varying screen sizes. A common technique was to use “breakpoints” to switch layouts. In this visualization, the vertical axis is the browser width and the horizontal axis shows the content vs margin:

Separate layouts for each device

I didn’t want to maintain multiple layouts. I wanted one layout that adapted smoothly based on the browser width, with no discontinuities:

One layout interpolating between breakpoints

In 2017 I went through my pages one by one and migrated them from the fixed 450px or 600px layout to use the new layout. During the transition my build systems supported all three.

In 2020 I wanted to take into account the reader’s preferred font size. I switched from px units to rem units. I didn’t realize until a few weeks ago that I got that conversion slightly wrong.

I decided to investigate. In converting px units to rem, I divided everything by 16. But somewhere in the intermediate calculations, I had rounded 0.625 to 0.6. I had made the mistake by manually calculating the breakpoints, and I fixed it by manually calculating everything again.

I decided I should automate the calculations. I already had most of the code written for the interactive diagrams, so I adapted it into a calculator. I can enter the breakpoints and it generates the CSS:

Interactive calculator based on breakpoints

While playing with the calculator I realized I didn’t like entering a lower breakpoint (515.5px @ 550px). I looked through my notes from 2017 and saw that I had actually calculated the lower breakpoint from a more fundamental value: the slope of the line on the diagram. A slope of ⅓ means that for each additional 3px of browser width, 1px goes to the left margin, 1px goes to the content, and 1px goes to the right margin. Whether that’s the best ratio I don’t know, but it’s what I’ve been using.

The last thing I did was to move the calculation to run inside CSS. This wasn’t feasible in 2017 but it works in current browsers using functions like min() and clamp(). I also use round() to make sure diagrams have an integer width, so that any <canvas> elements aren’t fractionally sized.

Layout using CSS calculations

Overall I think the first half of this project was hard to justify. Fixing the bug changed a fraction of a pixel, and that shouldn’t matter to anyone. But the second half of this project is potentially useful. I found a set of formulas that lets me adapt my layout to other sizes for future projects.

Try the interactive visualization here[1].