Hey could you remind me how to make the img
element responsively resize, relative to the width of its parent element, without exceeding its original size?
thanks
Hi @marachimeno,
You can add to the CSS this lines:
img {
width: 100%;
max-width: 400px;
height: auto;
}
In that example you are saying to the image: Ok…You will measure 100% of your width but you can’t be bigger than 400px (you can use the inherit
value to make the max-width equals the width of the parent). The height in auto helps to make a proportional scale.
I hope this helps you,
1 Like
I can’t get it to work…
I already fixed it, but thanks!