Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font-size with undfined CSS variable on :root causes wrong rem unit #1138

Open
MurakamiShinyu opened this issue Mar 5, 2023 · 0 comments
Open
Labels

Comments

@MurakamiShinyu
Copy link
Member

Test sample:

<!doctype html>
<style>
:root {
  font-size: var(--font-size);
}
p:nth-child(2) {
  font-size: 1rem;
}
</style>
<body>
  <p>TEST (font-size is inherited from root)</p>
  <p>TEST (font-size: 1rem; should be same as above)</p>
</body>

このように、ルート要素に font-size プロパティが指定されているがその値がCSS変数でそのCSS変数が未定義である場合、Vivliostyle Viewerの文字サイズを変えるボタンで文字サイズを変えようとした場合、ルートから継承される本文の文字サイズはデフォルトの16pxのままで変わらない。しかし、それにもかかわらずrem単位の大きさは変わり、実際のルートの文字サイズとrem単位の大きさが合わない不具合が生じる。

HTML: https://gist.githack.com/MurakamiShinyu/f53a80755b2ebc3a31908c655aa26376/raw/root-font-size-var.html

Test with Vivliostyle Viewer:
https://vivliostyle.vercel.app/#src=https://gist.githack.com/MurakamiShinyu/f53a80755b2ebc3a31908c655aa26376/raw/root-font-size-var.html&fontSize=24/16

Screenshot:
Screenshot 2023-03-05 at 22 18 34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant