7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

フォントサイズをemで指定するときにpx換算しやすい方法

Posted at

厳密には若干差が現れますが、ほぼ大差ないのでよく使っています。

bodyにフォントサイズを62.5%で設定します。
あとは各要素でサイズを指定するときに、12px→1.2em、14px→1.4emとします。

stylesheet.css
body{  font-size: 62.5% ; } /* 1.0em = 10px  */
p{ font-size: 1.2em; } /* 12px */
a{ font-size: 1.4em; } /* 14px */
7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?