ben03 Posted July 24, 2018 Share Posted July 24, 2018 Hi there, I just need something clearing up: I thought giving a font a rem made it relative to the font size set on the body. Then, giving that text's container an em would make it resize based on the contained text's size. However the text only appears to resize when the body font size is adjusted when set with an em. Am I doing this the wrong way round, or worse missing the point of em's and rem's altogether? Help appreciated here :) Link to comment Share on other sites More sharing options...
Ingolme Posted July 24, 2018 Share Posted July 24, 2018 You seem to have mixed them up. An element set in rem is always relative to the root of the document and nothing else, all of its ancestors are ignored. The em is relative to the font size of the element's immediate parent. Link to comment Share on other sites More sharing options...
ben03 Posted July 26, 2018 Author Share Posted July 26, 2018 Ok Ingolme, I think I understand. What I had been doing was the following, in the hope that by increasing the body font size would lead to all the values increasing proportionately (that is the point of rem and em, right?). But it wasn''t working... body{font-size: 16px;} button{font-size: 0.825rem; padding: 1em 1.2em;} What would I need to do to achieve this? Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted July 26, 2018 Share Posted July 26, 2018 rem uses the font size of the root of the document, that's not <body>, it's <html>. Link to comment Share on other sites More sharing options...
ben03 Posted July 30, 2018 Author Share Posted July 30, 2018 That would explain why that wasn't working then. Link to comment Share on other sites More sharing options...
ben03 Posted July 30, 2018 Author Share Posted July 30, 2018 and setting that in px would allow the tools to manipulate the base font size? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now