The Only Time I Used Math at Work - and It wasn t What You Think

Published: (December 30, 2025 at 01:07 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

My First “Simple” Task on the Team… Wasn’t So Simple

The requirement on paper:

Make the menu sticky and make sure it stays aligned with the content.

For most screen sizes it worked, but larger screens exposed a problem.

The Layout Looked Straightforward

  • A max‑width layout.
  • The sticky menu should stay aligned with the content column.

Where Things Started to Break

Ignoring large screens means ignoring real users who actually have them.

The Real Problem

Match the content width

I had to stop thinking in fixed pixel values.

At first glance it seemed simple:

x = margin‑left + padding-left + width of the content column

But the sticky menu width turned out to be the same variable x.

Breaking the Layout Down

After inspecting and resizing the screen repeatedly, I derived the following relationships:

100vw = 2y + 2P + B

where

  • 100vw – viewport width
  • y – half‑width of the sticky menu area
  • P – padding
  • B – border (or any extra spacing)

The sticky menu width is also:

x = y + C1 + P

where C1 is the fixed width of the content section itself.

Solving for y:

y = (100vw - 2P - B) / 2

Plugging this back into the first equation gives the responsive width needed for the sticky menu:

x = ((100vw - P - B) / 2) + C1 + P

The Final CSS

@media (min-width: 1439px) {
  .sticky {
    width: calc(((100vw - 1202px - 8px) / 2) + 794px + 4px);
  }
}

Final Thoughts

  1. Web development must consider big screens too—high‑resolution monitors are everywhere now.
  2. Math hides quietly in everyday front‑end work, just enough to make layouts behave.
  3. Sometimes being a developer means doing a little math… and honestly, that’s kind of perfect.
Back to Blog

Related posts

Read more »

Bad CSS-Dad Jokes (VI)

Jokes - Why are developers impressed with Tailwind? One semantic class is worth one thousand utility classes. - Why was the web developer afraid of accordions?...