Home › Forums › JavaScript › Change font-size while scrolling › Reply To: Change font-size while scrolling
February 1, 2018 at 9:28 pm
#266204
Shikkediel
Participant
Sure…
var mass = Math.max(2, 5-0.01*$(this).scrollTop()) + 'vw';
First number there (2
) is the minimum size in vw
it will shrink to, 5
should match what’s defined in the CSS and 0.01
is the factor that determines how fast it’ll shrink with scrolling.
Edit – using font-size
is how they do it on the example page you linked to. I think I would personally probably choose to go with a transform: scale
instead. Something like this: