The element on the left of the css is as high as the element on the right. How to center vertically?

The left element of the

css is as high as the right element. How to center vertically?
effect

clipboard.png


clipboard.png



span:nth-child(1){}


clipboard.png

but how to center vertically?

Dec.21,2021

this can be classified as a multi-column contour problem. In fact, you want to achieve two columns of equal height, it is not necessarily the same height, but the space height of the left and right columns of color seems to be the same.
the solution you have given above can be regarded as one, and there are some other ingenious solutions. You can poke this DEMO to see:

https://github.com/chokcoco/C.

.

isn't it easy to do it with table?


you use display:flex to make a contour layout, or it is difficult to set it in the middle.

// 
  display: flex;
  align-items: center;

disadvantage: css3 needs to be supported.


this is a very standard form

can be achieved directly with table , and the compatibility is good

.

can be laid out with flex, compatible with low-end computers with autoprefixer, this is the online address


add
display:table-cell;
vertical-align: middle;

where you need it.
Menu