So, I try to add the current window.pageYOffset
value as a marginTop
value for someone container on the page with onclick
event. But it does not happen.
Also I want to admit, that there is no problem with adding a positive value of the window.pageYOffset
to marginTop
.
Here my code:
let a = window.pageYOffset;
const rightColumn = document.querySelector('.right-side__column');
rightColumn.style.marginTop = '-' + a + 'px'; // in such way a in
// padding even equal to 0.
// rightColumn.style.marginTop = a + 'px'; - work fine, the value is transfer normally.