Image cut when decreasing page width

Asked

Viewed 94 times

1

I am developing a web application in jsp and Servlet and put an image in a bootstrap column <div class="col-11"></div> so I put the image in the center of the screen using themargin-left .But by decreasing the page width the image cuts

Image in normal page width

inserir a descrição da imagem aqui

Image cut with page width decreased

inserir a descrição da imagem aqui

  <div class="row">

   <div class="col-11"><img src="imagens/imagem1.JPG"class="imagem_principal" id="desconto" alt="desconto"></div>

    </div>
   #desconto{
width: 90%;
height: 60px;
margin-top: 30px;
margin-left: 70px;

  }

1 answer

2


This happens because the class col-11 apply the width through a percentage (relative measure) and you applied the margin in pixels (absolute measure).

To correctly center the image in the center of the screen, you first need to center the col-11 using justify-content-center in row. After that, it is necessary to center the image in the div using text-center.

<div class='row justify-content-center'>
    <div class='col-11 text-center'>
        <img src="imagens/imagem1.JPG"class="imagem_principal" id="desconto" alt="desconto">
    </div>
</div>
  • thanks Oeslei was just that

Browser other questions tagged

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