---
title: The most-read thing I ever wrote is a Stack Overflow answer
description: >-
  A six-line CSS answer I posted on a Saturday in 2013 has 478,000 views. Nothing on this blog comes
  close.
url: https://expiredqueues.com/most-read-thing-i-wrote/
markdown: https://expiredqueues.com/most-read-thing-i-wrote/index.md
date: '2026-08-24T09:00:00.000Z'
image: https://expiredqueues.com/images/og/most-read-thing-i-wrote-92c92454.jpg
---

Retrospect posts css

# The most-read thing I ever wrote is a Stack Overflow answer

24 August 2026 By Adrian Noel 2 min read

On this page

1. [The question](#the-question)
2. [The 2013 answer](#the-2013-answer)
3. [The answer today](#the-answer-today)
4. [Why the old answer was right in 2013](#why-the-old-answer-was-right-in-2013)
5. [The one edit](#the-one-edit)

[On a Saturday in October 2013](https://expiredqueues.com/six-weeks-in-2013/index.md) I answered [a question on Stack Overflow](https://stackoverflow.com/a/19193308). It asked how to size an image against its parent's height. That question now has 478,000 views. Nothing I've published here in sixteen years comes close.

## The question

Someone had a fixed-size box and images of different dimensions. They wanted each image to fill the box without squashing.

## The 2013 answer

```css
.img-wrap {
  width: 200px;
  height: 150px;
  position: relative;
  overflow: hidden;
}

.img-wrap > img {
  position: absolute;
  top: 50%;
  left: 50%;
  min-height: 100%;
  min-width: 100%;
  transform: translate(-50%, -50%);
}
```

How it works:

1. `min-width: 100%` and `min-height: 100%` keep the image at least as large as the box on both axes. There's no gap to fill.
2. `overflow: hidden` cuts off whatever spills over.
3. `top: 50%` and `left: 50%` move the image's top-left corner to the middle of the box.
4. `translate(-50%, -50%)` moves the image back by half of its own size. Percentages in `translate` resolve against the element, not the parent.

Steps 3 and 4 together still center an element whose size you don't know.

I wrote about six hundred words to explain it. I signed off with "Apologies for taking too long to explain!"

## The answer today

```css
.img-wrap {
  aspect-ratio: 4 / 3;
}

.img-wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
```

You don't need positioning, overflow or a transform. `object-fit: cover` does the same job.

## Why the old answer was right in 2013

When I posted it, no browser had shipped `object-fit`:

| Browser           | Shipped `object-fit` |
| ----------------- | -------------------- |
| Chrome            | Early 2014           |
| Safari            | Later in 2014        |
| Firefox           | 2015                 |
| Edge              | 2017                 |
| Internet Explorer | Never                |

For several years after 2013, the hack was the only option that worked in every browser.

## The one edit

[The answer was edited once, in September 2017](https://expiredqueues.com/answers-i-went-back-to-fix/index.md). That's four years after I posted it. Stack Overflow doesn't tell you who made an edit, only when. Other people can edit your posts there too. The edit tidied the prose and left the CSS alone, which is roughly [how old answers rot](https://expiredqueues.com/answers-need-expiry-dates/index.md).

**Expired Queues is on YouTube.** Short videos on the same topics as this blog.

[Watch on YouTube](https://www.youtube.com/@expiredqueues)

[Previously Every answer needs an expiry date](https://expiredqueues.com/answers-need-expiry-dates/index.md) [Next A lightweight theme toggle extension that's better than Dark Reader](https://expiredqueues.com/shadeflip-dark-reader-firefox-chrome-extension/index.md)

## Structured data

```json
{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "The most-read thing I ever wrote is a Stack Overflow answer",
  "description": "A six-line CSS answer I posted on a Saturday in 2013 has 478,000 views. Nothing on this blog comes close.",
  "datePublished": "2026-08-24T09:00:00.000Z",
  "dateModified": "2026-08-24T09:00:00.000Z",
  "author": {
    "@type": "Person",
    "name": "Adrian Noel",
    "url": "https://expiredqueues.com/about/"
  },
  "publisher": {
    "@type": "Person",
    "name": "Adrian Noel"
  },
  "mainEntityOfPage": "https://expiredqueues.com/most-read-thing-i-wrote/",
  "keywords": "posts, css, stack-overflow, tips-tricks",
  "articleSection": "Retrospect"
}
```
