# Fit height to background pattern size with calc-size()

DevFeed: [Fit height to background pattern size with calc-size()](<https://devfeed.tech/articles/fit-height-to-background-pattern-size-with-calc-size-87686.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/fit-height-background-pattern-calc-size/>)

Author: Ahmad Shadeed

Published: 2026-10-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [human computer interaction](<https://devfeed.tech/topics/human-computer-interaction.md>), [web graphics](<https://devfeed.tech/topics/web-graphics.md>)

Tags: [background-size](<https://devfeed.tech/tags/background-size.md>), [calc](<https://devfeed.tech/tags/calc.md>), [css](<https://devfeed.tech/tags/css.md>)

## AI overview

A CSS tutorial shows how to align a repeating background pattern with a section's height using calc-size() and round(). It notes that the approach works in Chrome and Edge but is unavailable in Firefox and Safari, and demonstrates rounding the height and padding to multiples of the pattern tile height.

## Source excerpt

## The problem I have a section with a background pattern that repeats on both axes. I wanted the vertical repeat to be aligned with the pattern's height, so the pattern won't have cut-offs. Take the following design. ``` .section { --tile-width: 52px; --tile-height: 44px; background-image: url("pattern.png"); background-size: var(--tile-width) var(--tile-height); } ``` The Espresso Guide Everything you need to pull a great shot at home: picking the right beans, dialing in your grind size.