Home > other >  Resize image to parent div? Using parent div only?
Resize image to parent div? Using parent div only?

Time:10-15

I have an image inside a div. image should resize itself base on this div’s dimensions (without messing up the ratio)

<div class="w-50">
  <img src="" class="w-full h-full image-cover">
</div>  

However I can only change the div class and not the image tag class. So things like: max-h-full max-w-full object-contain haven’t been working.Any work arounds?

CodePudding user response:

try this

.w-50 img { width:100%;}

CodePudding user response:

You can try:

.w-50{
width:100%
or
margin:
}
  • Related