I have a 48x48 div and inside it there is an img element, I want to fit it into the div without losing any part, in the mean time the ratio is kept, is it achievable using h
div { width: 48px; height: 48px; } div img { display: block; width: 100%; }
This will make the image expand to fill its parent, of which its size is set in the div CSS.
div