Home / Tài liệu CNTT / CSS-CSS3 / Highlight current section in navbar | menu item on scroll Codepen

Highlight current section in navbar | menu item on scroll Codepen

Thường sử dụng cho các theme one-page, hay highlight danh mục, index section của 1 trang.

Code 1: Highlight menu item on scroll

HTML:

CSS:

JS:

Demo: https://codepen.io/zbymhz/pen/ExjRNwZ

Code 2: Detect and Highlight current section in navigation

HTML:

CSS:

JS:

Demo: https://codepen.io/davidicus/pen/mEVdPN

Code 3: IntersectionObserver – highlight current section

HTML:

CSS:

JS:

Demo: https://codepen.io/mishunov/pen/opeRdL