0

I have one rectangle and inside of this one, I have created two more. I would like to show these two rectangles exactly in the middle of the height of the first one.

The result that I would like to obtain would be the yellow and white squares in the half height of the blue square.

.space-around {
    display: flex;
    justify-content: space-around;
}

.rectangle {
    height: 100px;
    width: 200px;
    background-color: blue;
}

.rectangle-left{
    width: 20px;
    height: 40px;
    background-color: white;
}

.rectangle-right{
    width: 20px;
    height: 40px;
    background-color: yellow;
}
<div class="rectangle space-around">
  <div class="rectangle-left"></div>
  <div class="rectangle-right"></div>
</div>
bellotas
  • 2,349
  • 8
  • 29
  • 60

1 Answers1

1

Use align-items: center

.space-around {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.rectangle {
    height: 100px;
    width: 200px;
    background-color: blue;
}

.rectangle-left{
    width: 20px;
    height: 40px;
    background-color: white;
}

.rectangle-right{
    width: 20px;
    height: 40px;
    background-color: yellow;
}
<div class="rectangle space-around">
  <div class="rectangle-left"></div>
  <div class="rectangle-right"></div>
</div>
Michał Drabik
  • 425
  • 4
  • 8