Ich habe einen Container und im Inneren gibt es 3 Boxen: gelb, grün und rot.Flex-Elemente auf der rechten Seite ausrichten
Ich gab display:flex
in den Container und gab justify-content:flex-start
für die Elemente an Anfang zu starten.
Ich wollte die rote Box bis zum Ende verschieben, also gab ich margin-right: auto
an die gelbe Box, so dass die rote Box zum Ende bewegen konnte (nicht sicher, ob dies die genaue Art ist, die rote Box zu Ende zu bewegen, wenn nicht Ich will auch Hilfe darin).
Die Frage ist also: ich das grüne Feld in der vertikalen Mitte des Behälters will und ich mag es ganz rechts wie die rote Box bewegen (aber in der Mitte des Behälters sein soll)
Wie mache ich das mit der Flexbox?
.container {
height: 500px;
width: 500px;
background-color: royalblue;
display: flex;
flex-direction: row;
justify-content: flex-start;
}
.yellowbox {
color: black;
height: 100px;
width: 100px;
background-color: yellow;
margin-right: auto;
}
.greenbox {
color: black;
height: 100px;
width: 100px;
background-color: green;
align-self: center;
margin-left: auto;
}
.redbox {
color: black;
height: 100px;
width: 100px;
background-color: red;
}
<div class="container">
<div class="yellowbox">
<p>the white text</p>
</div>
<div class="greenbox">
<p>the black text</p>
</div>
<div class="redbox">
<p>the red text</p>
</div>
</div>
THIS IS MY CODEPEN LINK: http://codepen.io/ShamZ/pen/pRLELP