I have an image of 400px and a div that is smaller (the width is not always 300px as in my example). I want to center the image in the div, and if there is an overflow, hide
Most recent solution:
HTML
CSS
.parent { width: 200px; height: 200px; overflow: hidden; /* Magic */ display: flex; align-items: center; /* vertical */ justify-content: center; /* horizontal */ }