On my html I have 3 buttons(will be seen on my page on one section) and each button has a related image. When you start from the top, you will see the 3 buttons on the left and on the right the image from the button that is selected.It will start at first with the first button selected.
The idea is while scrolling down until some height, I want to change the button that is active to the second one and also change the image on the right. Then when continue scrolling again it should select the third button and its image.
Which event or css styling should I use to have this behavior ? Should I use intersection observer ?
I want to use Html, css & js
<section
style="display: flex; flex-direction: column; padding-left: 100px; height: auto; position: sticky; top: 0"
>
<button style="width: 100px; height: 100px; background-color: red">
Button 1
</button>
<button style="width: 100px; height: 100px">Button 2</button>
<button style="width: 100px; height: 100px">Button 3</button>
<button style="width: 100px; height: 100px">Button 4</button>
<button style="width: 100px; height: 100px">Button 5</button>
<button style="width: 100px; height: 100px">Button 6</button>
<button style="width: 100px; height: 100px">Button 7</button>
</section>
<section style="height: 200px">Section 2</section>
<section style="height: 200px">Section 3</section>
<section style="height: 200px">Section 4</section>
<section style="height: 200px">Section 5</section>