1

I would like to achieve this: .right must be aligned vertically to center, but must be placed at the very end of the .wrap just like below.

enter image description here

Here is my code:

.wrap {
  display: flex;
  box-shadow: 0 0 0 1px black;
  height: 400px;
  align-items: center;
}
.wrap > * {
  box-shadow: 0 0 0 1px black;
  padding: 20px;
}
.right {
  align-self: flex-end;
}
<div class="wrap">
  <div class="left">1</div>
  <div class="nextToLeft">2</div>
  <div class="right">3</div>
</div>

Codepen

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
user7376146
  • 63
  • 1
  • 5

2 Answers2

2

Just add margin-left:auto;

.right {
  margin-left:auto;
}
Ashot Khanamiryan
  • 1,102
  • 12
  • 19
1

<html>
<head>

<style>

.wrap {
display: flex;
box-shadow: 0 0 0 1px black;
height: 400px;
align-items: center;
justify-content: space-between;
}

.wrap > * {
box-shadow: 0 0 0 1px black;
padding: 20px;
}

.nextToLeft {
margin-right: auto;
}

</style>
</head>

<body>
<div class="wrap">
<div class="left">1</div>
<div class="nextToLeft">2</div>
<div class="right">3</div>
</div>
</body>

</html>
Raj
  • 1,928
  • 3
  • 29
  • 53