Side-by-side images aligned on any screen

Asked

Viewed 40 times

1

HTML

<a href="index.html"><img src="imgs/Logo Aguia vet.png" alt="Logo Aguia Informatica" class="responsive"></a>
<a href="http://mactronengenharia.com.br/" target="_blank"><img src="imgs/mactron engenharia.png" alt="Logo Mactron Engenharia" class="responsive"></a>
<a href="#" target="_blank"><img src="imgs/aldosolar.png" alt="Aldo Solar" class="responsive"> </a>

CSS

.responsive { /*Logos rodapé*/
    display: inline-block;
    margin-left: 9em;
    margin-right: auto;
    width: 100%;
    max-width: 250px;
    height: auto;
}   
  • 2

    Hello. It would be interesting if you would pass us more details about the situation and more code

2 answers

1

Your code is almost right, the problem is how you used the class and some properties that are unnecessary...

inserir a descrição da imagem aqui

You put the class right in the image, but the most appropriate to my view would be to create a container and put the class in this container.

.responsive { /*Logos rodapé*/
  display: inline-block;
  /* margin-left: 9em; */
  /* margin-right: auto; */
  width: 100%;
  /* max-width: 250px; */
  height: auto;
  text-align: center;
}   
<div class="responsive">
  <a href="index.html"><img src="https://placecage.com/100/100" alt="Logo Aguia Informatica" ></a>
  <a href="http://mactronengenharia.com.br/" target="_blank"><img src="https://placecage.com/100/100" alt="Logo Mactron Engenharia" ></a>
  <a href="#" target="_blank"><img src="https://placecage.com/100/100" alt="Aldo Solar" > </a>
</div>

  • Vlw worked cool.

  • @Caiocésarrubo cool that worked, if you think you solved the problem consider mark the answer as accepted in this icon next to the arrows . So your question does not go unanswered even though it has already been resolved.

0

If you need images side by side, you can use the display: flex with the properties, justify-content: center; and align-items:center; that they will align all the contents of their div side by side. The display: flex already comes as standard flex-direction: row, if you need the images to be below each other, you just need to change to flex-direction: column.

div {
  display: flex;
  justify-content: center;
  align-items:center;
}

img {
margin: 2.5px;
height: 5em;
width: 5em;
}
<div>
  <img src="https://pbs.twimg.com/profile_images/711520911082569728/CZvvAEVD.jpg">
    <img src="https://pbs.twimg.com/profile_images/711520911082569728/CZvvAEVD.jpg">

  <img src="https://pbs.twimg.com/profile_images/711520911082569728/CZvvAEVD.jpg">

</div>

  • Using flex really addresses the "aligned on any screen", note also, if there is a need for IE9 support (even 10 and 11 due to many bugs), use the @hugocsl solution

  • Using the visual studio the flex did not work, the above suggestion solved my problem.

Browser other questions tagged

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