Change justify-content value when flex items overflow container
justify-content is not the right approach to center because of the problem you describe. Instead, I recommend auto margins. You can use them to center: Prior to alignment via justify-content and align-self, any positive free space is distributed to auto margins in that dimension. And they behave as you want with overflow: Overflowing boxes ignore … Read more