A
A
Alexander2018-03-18 13:38:15
JavaScript
Alexander, 2018-03-18 13:38:15

How to change css property simultaneously with page scroll?

For example, there is St.

position: fixed;
top: 50px;

It is necessary that top changes relative to page scrolling until it reaches 0, and then it is fixed. With fixation, for example, you can do this:
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50)

But how to do the rest?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-03-18
@pi4yyy

https://learn.javascript.ru/onscroll

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question