I would love to put the images in logos related to the center of the boxes.
https://pnghunter.com/logo/acura-nsx-gray/
How can I affect this?
I would love to put the images in logos related to the center of the boxes.
https://pnghunter.com/logo/acura-nsx-gray/
How can I affect this?
Add css properties display: block; margin: 0 auto
to the images.
You can also use flexbox. Add the following css properties -
display: flex;
align-items: center;
justify-content: center;
You'll need to display the image as block
and add auto
margin to both sides (left & right).
.container {
background-color: gray;
padding: 30px 0;
}
img {
width: 50%;
/* This will do the trick */
display: block;
margin: 0 auto;
}
<div class="container">
<img src="https://purepng.com/public/uploads/large/purepng.com-acura-nsx-graycarvehicletransportautocars-561521125226tokdl.png" alt="Car">
</div>
Alternative: Use flexbox
. Will not be as robust as auto-margins due to many bugs still present in IE. However, if the parent's height is set, this will also center vertically.
.container {
background-color: gray;
padding: 30px 0;
/* Here comes the magic */
display: flex;
justify-content:center;
align-items: center;
}
img {
width: 50%
}
<div class="container">
<img src="https://purepng.com/public/uploads/large/purepng.com-acura-nsx-graycarvehicletransportautocars-561521125226tokdl.png" alt="Car">
</div>
put this css rules...
.logo__container{
display: flex;
align-items: center;
justify-content: center;
}
You should use flexbox for this. Add the following css to the containers (logo__container):
display: flex;
justify-content: center; //horizontal
align-items: center; //vertical