alazizie alazizie - 1 month ago 4x
CSS Question

How to make a div resizable like in (background-size:100%)?

I want a div height/width to be dynamically resized together when window width is resizing just like in (background-size:100%), and I prefer using only CSS "if possible".

Thank you in advance :)


You can set width:100%; and height:auto; Also try to do the same for images inside that div


That will make the img responsive and will not overflow the parent div

Also you can use this

img {
    max-width: 100%;
    height: auto;

The image will scale down if it has to, but never scale up to be larger than its original size