I've created a navigation tab with links to different sections of the page, each identified by unique ids:
<section id="1"></section>
<section id="2"></section>
<section id="3"></section>
These sections are then linked in the navigation bar like so:
<a href="#1"></a>
Now I'm looking to add custom styling to these navigation links when their corresponding section is visible in the browser viewport.
Currently, when a link is clicked, the id is added to the URL. However, I want the styling to apply even if the user hasn't clicked any links, making this solution inadequate for my needs.
Is there a CSS property that can be checked using JavaScript to determine if a specific section is in view?
I'm seeking a solution that is responsive across various screen sizes.