CSS force image resize and keep aspect ratio
Expand snippet This will make image shrink if it’s too big for specified area (as downside, it will not enlarge image).
Expand snippet This will make image shrink if it’s too big for specified area (as downside, it will not enlarge image).
Just create a wrapper <div> with a percentage value for padding-bottom, like this: Run code snippetExpand snippet It will result in a <div> with height equal to 75% of the width of its container (a 4:3 aspect ratio). This relies on the fact that for padding : The percentage is calculated with respect to the width of the generated box’s containing block … Read more