I am having to use auto margins to align content in the center of the page.
div {
background: #121212;
font-size: 100%;
display: flex;
}
a {
color: #fff;
padding: 2%;
display: inline-block;
background: linear-gradient(180deg, rgba(18, 18, 18, 0.8) 0%, rgba(18, 18, 18, 0.5) 66.66%), url('https://cml.sad.ukrd.com/image/714544.png');
background-size: cover;
background-position: top;
white-space: nowrap;
font-size: 18px;
}
img {
height: 100%;
width: auto;
display: flex;
align-self: center;
max-height: 50px;
margin: 0 auto;
/* fails justify-self: center; */
}
<div>
<a href="#">⟵ Some Text Goes Here</a>
<img src="https://cml.sad.ukrd.com/image/714824.png">
</div>
I want to discover how to position the blocks image in the centre of the parent div. The div already has another <a>
child, which is pushing the block image slightly out of the centre. The div parent is a flexbox, and I assumed having a justify-self: center
rule would work, but apparently not, hence why I've had to use margin: 0 auto
, which doesn't competely centre align it anyway.
How can the block image be in the dead centre of the parent div?