Closed HungerDeng closed 1 week ago
Not a Plasmo bug, rem
is always going to refer to what font-size
is set in the documents <html>
(it's also not valid to nest <html>
tags), you have to handle this yourself.
As this is a common issue, you can probably search for workarounds to use em
instead of rem
with Tailwind (for example: https://github.com/tailwindlabs/tailwindcss/discussions/3768) if you want to ignore the font-size
set in the webpage root.
@tbrockman I really appreciate you taking the time to answer. As a front-end beginner, your response has been incredibly helpful to me. Thank you! I don't have any further questions, so I will go ahead and close this issue.
@HungerDeng No problem! Hope you're able to find a way to get things working.
A bug occurred!
I used rem to set the font size, for example, font-size: 0.5rem. Some websites, like youtube.com, customize the HTML element's font size to 10px. This results in a computed font size of 0.5 * 10 = 5px.
However, the font size of the HTML tag can vary across different websites, which leads to inconsistent font sizes in my content-script-ui (CSU). Moreover, I cannot modify the website's own defined font size, as that would affect the page's display.
I found the definition of rem online:
To address the issue, I tried wrapping my CSU in an HTML tag like this:
However, this didn't standardize my rem unit sizes in different website. The computed results of 0.5rem still is 5px, which youtube.com own defined html-font-size is 10px. What i wanted is 8px (0.5 * 16px) If I use Tailwind CSS, this issue becomes even more pronounced, as many utility classes (liked h-4, p-4 ...)in Tailwind are based on rem for size calculations.
How can I resolve this issue? I look forward to your response.
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Chrome
Relevant log output
(OPTIONAL) Contribution
Code of Conduct