N
N
nagibator2282020-04-29 21:02:00
css
nagibator228, 2020-04-29 21:02:00

How to set text vertically in css in flex block?

All pis, I can not put the text in the blocks in the center vertically. Searched the internet, vertical-align , align-content , etc. do not help (or I'm too dumb and put them in the wrong place)

Here is the code

--html--
<div class="wrapper">
<div class="block -block--up">А</div>
<div class="block -block--up">Б</div>
<div class="block -block--down">В</div>
<div class="block -block--down">Г</div>
<div class="block -block--down">Д</div>
</div>

--css--
.wrapper{
  display: flex;
  border: solid 1px black;
  height: 60px;
  width: 240px;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
}
.-block--up{
  width: 120px;
}
.-block--down{
  width: 80px;
}
.block{
  height: 30px;
  text-align: center;
  outline: 1px solid black;
}


Link to the code on jsfiddle

And here is what should happen
5ea9bfbc24214636890570.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lord_Dantes, 2020-04-29
@nagibator420

display:flex;
align-items: center;
justify-content: center;
height: must be a height.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question