How css sets the row height to 100% of the element height

    line-height: ???;

do not want to set a fixed px, because it will change, how to set it to follow the element height 100%?

Feb.24,2022

vertical-align:middle;display:inline-block;


pinch like this

line-height:calc(100% - 0px);

if you just want the text to be centered vertically, you can use display:table-cell; or flex


line-height:1


if you don't mind the amount of code, you can center it by positioning, which is not recommended. Flex


is recommended.

increase pseudo class, 100% height. Then modify the horizontal center.

http://jsrun.net/eChKp/edit

clipboard.png

Menu