JSFiddle - React, Tailwind, and code Playground
HTML
<div class="wrapper">
<h1>
Hello
</h1>
<a href="#">
<img src="//unsplash.it/100/100" />
</a>
<a href="#">
<img src="//unsplash.it/100/100" />
</a>
</div>
<div class="wrapper1">
<h1>
Hello
</h1>
<a href="#">
<img src="//unsplash.it/100/100" />
</a> <a href="#">
<img src="//unsplash.it/100/100" />
</a>
</div>
CSS
/** Allgemeines Zeug .. brauch dich nicht zu interessieren */
/* ist nur damit es einen schöneren effekt hat ;) */
.wrapper,
.wrapper1{
display: flex;
height: 104px;
border: 1px solid black;
width: 100%;
margin-bottom: 50px;
}
a {
width: 150px;
background-color: blue;
margin: 2px;
}
/*=============================0
Was du aktuell machst:
================================*/
.wrapper a img {
display: block; /* <=== das hier machst du nicht .. ist nur um es dir zu verdeutlichen .. ohne würde nichts passieren */
margin-left: auto;
}
/* damit wird das Bild IN dem Anchor nach rechts gepackt */
/*=============================0
Was du machen solltest
================================*/
.wrapper1 a:first-of-type { /* :first-of-type sorgt wie gesagt dafür, dass der Style nur auf das erste a übertragen wird, was in wrapper1 liegt */
margin-left: auto;
}
/* damit wird das gesamte Anchor nach rechts geschoben */