How to center and position side by side two images? html css

Asked

Viewed 4,346 times

0

como quero q fique

HTML:

<div id="ladoalado"><img src="imgs/login.png"><img src="imgs/cadastro.png"></div> 

CSS:

#ladoalado{
    float: left;
    margin: auto;
}

Code image:

inserir a descrição da imagem aqui

2 answers

7


You can use for example display:flex for that reason.

See how it looks in the example, I left the comments in the code.

#ladoalado{
    display: flex; /* coloca as imagens uma ao lado da outra */
    justify-content: center; /* alinha as imagens no centro da tela */
}
<div id="ladoalado"><img src="https://unsplash.it/100/100"><img src="https://unsplash.it/101/100"></div> 

0

Only by complementing the Hugocsl response, use the property justify-content: space-around;

justify-content: space-around; creates equal spaces before, between and after your HTML elements.

See in the example below...

#ladoalado{
   display:flex;
   justify-content: space-around;
   
}
<div id="ladoalado"><img src="https://unsplash.it/100/100"><img src="https://unsplash.it/101/100"></div>

Browser other questions tagged

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