Entry 07
Safe alignment
Use it wherever content is centered or end-aligned in a container that can become too small, such as a tab row, a toolbar or a vertically centered modal.
Code
.tabs {
display: flex;
overflow-x: auto;
justify-content: safe center;
}Why it works, the rules and the credits
Why it works
- Plain
centerpushes overflow off the start edge, where scrolling cannot reach it.safefalls back tostartonce the content overflows.
Rules
- It works on every
align-*,justify-*andplace-*property. - Auto margins on the item center it the same way and are safe in every browser that has flexbox. Push one item away with an auto margin has them.
Support
- Chrome
- 115
- Firefox
- 63
- Safari
- 17.6
Credits
Borrowed from: Temani Afif, Safe align your content, 2025-06-10