undefinedfix
Sign in

How to set row height to 100% of element height in CSS

cheft edited in Sat, 28 May 2022
    line-height: ???;

I don't want to set a fixed Px, because it will change. How to set it to follow 100% of the element height?

6 Replies
Whitemetalco
commented on Sat, 28 May 2022

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

alxh28
commented on Sat, 28 May 2022

If you just want to center the text vertically, you can use display:table-cell; Or flex

qgazn
commented on Sun, 29 May 2022

line- height:1

Mario
commented on Sun, 29 May 2022

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

marko
commented on Sun, 29 May 2022

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

http://jsrun.net/eChKp/edit

clipboard.png

suxbr
commented on Sun, 29 May 2022

It's like this

line-height:calc(100% - 0px);
lock This question has been locked and the reply function has been disabled.