Resize img inside a div

Asked

Viewed 361 times

1

Hello, I have a website that has posts... and in some posts I put pictures on them, but these images are not responsive! and there’s no way to change her class to a responsive class... because these posts are taken from a database for $variables I’ve tried through css this:

.welcome-content > img {
  max-width: 100%;
  height: auto;    
   }

but unsuccessfully... can anyone tell me any way whenever I have an "img" inside the div "Welcome-content" to get responsive? like, leave a responsive image I know!! but I want all the images that are in the "Welcome-content" div that in this case will not have a responsive class.

My div is like this:

<div class="welcome-content" align="left">
        <?php if($descricao != null){?><p class="descricao"><?php echo $descricao;?></p><? }?>

        <?php if($imagem != null){?><p><img src="<?php echo $imagem;?>" class="foto"/></p><? }?>

        <p><span class="glyphicon glyphicon-time" aria-hidden="true"></span> Postado em: <?php echo $data." às ".$hora;?> <br>
<?php if($postador != null){?>Postado por: <?php echo "$postador";?> <img src="https://minotar.net/avatar/<?php echo $postador?>/20"></p><? }else{
    echo "<p>Postado por: não informado</p>";
} ?>

    </div>

and my css :

.welcome-content { 
    background-color: #fff;    
    padding: 5px 20px; 
    padding-bottom: 10px; 
}

.welcome-content > img {
    max-width: 100%;
    height: auto; 
}
  • How is the HTML of these images? Post the question that makes it easier to analyze the problem.

  • By the way, have you tried using !important? Type: max-width: 100% !important;

  • Yes, yes........

  • That class foto does what?

  • The selector is wrong. The right one would be .welcome-content p img{

  • She doesn’t do anything. She wasn’t even supposed to be there.

  • The image is inside a p

  • Wow.. I would never have noticed! Thank you!!

Show 3 more comments

1 answer

0


You’re using the wrong selector:

.welcome-content > img

See that the image is still within a paragraph <p>, soon had to be:

.welcome-content p img
  • Thank you very much! I will already accept the answer, I have to wait 2 minutes.

  • 1

    Obg friend! God pay you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.