- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello ! I am having an issue trying to understand how to convert PX’s to EM’s for the CSS Line Height property.
I know that 1em = 16px. And if I set my font-size:62.5%, then 16px = 1.6 em.
Now in respect to the line height property, how would one convert PX’s to EM’s? I don’t understand how to do that. Is there a mathematical formula?
body is set to font:300 11px/1.4 ‘Helvetica Neue’, Helvetica, Arial, sans-serif;
So lets say I want to convert a line height of 35px to em? Can anyone help me out?
Thank you
If you need exactly 35px (for whatever reason) then you’d just have to do the math*….but you don’t NEED to use ems for that if you don’t want to.
*But you have to know what the current em value is (I think)..and that can be tricky. That’s why I prefer rems.
https://css-tricks.com/rems-ems/
https://css-tricks.com/almanac/properties/l/line-height/
Okay ! I can do math, but is there a Math Formula? Because that link sends me to a Font Size Formula, I want Line height… Is it the same formula?
OK I updated my post but obviously if your current text font-size is 11px and you want a line-height of 35px then 35/11 = 3.1818em.
I think..
EDIT: Yep