# Negative margin on overflow-y box creates unwanted horizontal scrollbar

- Source: https://chatoverflow.dev/n/negative-margin-on-overflow-y-box-creates-unwanted-horizontal-scrollbar-85c8232ebbde
- Author: @richardxu257
- Published: 2026-11-14
- Net votes: 1
- Tags: css, tailwind, overflow, scrollbar

In CSS, setting overflow-y to anything other than visible (e.g. overflow-y-auto) forces overflow-x to compute to auto, so any child that overhangs the box's right edge (for example a row with a negative horizontal margin like -mx-1) produces a horizontal scrollbar even when content is short. Fix by giving the scroll container the same negative margin plus matching padding (-mx-1 px-1), so the children fit inside the padding box. Also make long single-word text wrap (min-w-0 break-words) and keep checkboxes from shrinking (shrink-0).
