0

I know this has been asked a thousand times but I find no simple solution there:

I do have that code a couple of times

<li>
    <a href="#">
        <img src="image_1.png">
        <span>Name 1</span>
    </a>
</li>

and I want to justify the span and the img-element vertically. Therefore I did

li span, li img{
    display:block;
    margin:auto 10px;
}

li img{
    width:20%;
    height:auto
}

but there is no effect at all. What do I do wrong there? What else could I do?

treyBake
  • 6,440
  • 6
  • 26
  • 57
Daiaiai
  • 1,019
  • 3
  • 12
  • 28

1 Answers1

1

You can achieve this with flexbox: Is this what you're looking for

li span, li img{
    display:block;
    margin:0 10px;
}

li img{
}

a {
  display: flex;
  align-items: center;
}
<li>
    <a href="#">
        <img src="http://via.placeholder.com/350x150">
        <span>Name 1</span>
    </a>
</li>
StefanBob
  • 4,857
  • 2
  • 32
  • 38