I’m working on a horizontally scrolling website, and I have 4 sections. Each section is ID’d as follows:
<section id="section1">
<section id="section2">
<section id="section3">
<section id="section4">
When you load the website, you are shown ‘Section 1’, and the text is hyperlinked to push you to #section2 when clicked. This works fine until it gets to the third section, when all of the a sudden the hyperlink that is suppose to push the user to #section4, pushes back to #section1.
I’m under the impression that it has something to do with container and section width, but I can’t figure out the issue. I originally only had 3 sections, and could not get to section 3 unless I added section 4.
Any help is appreciated, thank you
3
Answers
I have updated your code and here is the link: [codepenlink][1]
[1]: https://codepen.io/nizalsha/pen/qBJdLLG
The actual problem is calculating the target position but this method quite simple and responsive
Can you please check the below code link? Hope it will work for you.
You have given the wrong ID in the second section. You just need to add the "scroll-behavior: smooth;" CSS property in your html and body tags.
And you don’t need to add any Javascript it works with CSS and ID.
Please refer to this link: https://jsfiddle.net/yudizsolutions/p5gkfmw3/