Giving my different sections their own height to be able to make them overlap each other. I got it working, but the javascript only loads when the page refreshes.
Is it possible to add some code so that my code updates when the window size changes in real time?
And, I understand that my way of distinguishing the three different panels is a shortcut. Is it possible to write the code so that it calculates each unit by itself, which would make it easier if I want to add sections.
let div = document.querySelector(".panel-01")
var height = document.querySelector(':root');
height.style.setProperty('--height', div.clientHeight + "px");
let div2 = document.querySelector(".panel-02")
var height = document.querySelector(':root');
height.style.setProperty('--height-2', div2.clientHeight + "px");
let div3 = document.querySelector(".panel-03")
var height = document.querySelector(':root');
height.style.setProperty('--height-3', div3.clientHeight + "px");
.panel-01 {
top:calc(100vh - var(--height));
}
.panel-02 {
top:calc(100vh - var(--height-2));
}
.pangel-03 {
top:calc(100vh - var(--height-3));
}