I've spent the past few hours trying to get the Bootstrap 4 scrollspy working so that as the user scrolls down the page, the relevant menu items are highlighted accordingly, but nothing I try works, so I'm clearly missing something.
I've applied the data-spy="scroll" attribute to the scrollable element that is being spied on, i.e. the body element and added a data-target attribute on the scrollable element with an ID of (what I believe to be) the parent element of the Bootstrap .nav component so that nav links can be targeted by the scrollspy for highlighting purposes. I've tried various iterations for positioning this, but still can't get it to work. The nav is collapsable depending on the viewport width, so it needs to work for both.
I've then added the relevant IDs to the appropriate sections, so I was assuming this would work.
Many thanks for this, it works perfectly. I had assumed that because Bootstrap allows both nave menus with and without an unordered list structure, that Scrollspy would work with both iterations. None of the tutorials I'd googled made mention of the specific need for an unordered list being essential to make Scrollspy work, but looking at them now, that does appear to be the one thing they all have in common, you live and learn...
Thanks for your help with this, very much appreciated.