LoginSignup
3
3

More than 5 years have passed since last update.

font-sizeをどの幅でも縮小拡大するvw単位の使い方

Last updated at Posted at 2018-04-10

vwの単位が幅によって拡大縮小はするのですが
1vw,2vwなどこれが何pxになるのかわからない。

例えば414pxの幅にfont-size:16pxを表示させたいと言うはXvwになるのか?

比率を計算するのは
414px : 100vw = 16px : Xvw
Xvw = ( 16 * 100 ) / 414px
3.864734299516908vwとなる。

これをいちいち計算して入力しても構わないのですが、
calcを使用すればこう言う書き方ができます。

font-size: calc( ( 16 * 100vw ) / 414 );
3
3
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
3
3