You can't divide a px
value by a viewport-width increment, but you can achieve this inverse size behavior reducing a px
value by a viewport-width increment.
Example:
font-size: calc(40px - 2vw);
Codepen DEMO
Alternatively, you could use the other 3 units related to the viewport's size: vh
vmin
and vmax
.
Examples:
font-size: calc(40px - 2vh);
font-size: calc(200px - 20vmin);
font-size: calc(200px - 20vmax);
vw - Relative to 1% of the width of the viewport*;
vh - Relative to 1% of the height of the viewport*;
vmin - Relative to 1% of viewport's* smaller dimension;
vmax - Relative to 1% of viewport's* larger dimension;
*viewport = the browser window size.
Source: w3schools
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…