Lesson 27: Scrollspy in Bootstrap 5

Scrollspy is an effect that displays content as you scroll. And you can easily create Scrollspy in Bootstrap 5.

Scrollspy is an effect that displays content as you scroll. And you can easily create Scrollspy in Bootstrap 5 .

 

How to create Scrollspy in Bootstrap

Scrollspy is often used to automatically update links in a navigation list based on the mouse scroll position. You can use the following sample code to create scrollspy in Bootstrap 5 .

 
 

Section 1

Try to scroll this page and look at the navigation bar while scrolling!

 . 

Detailed explanation:

In addition data-bs-spy="scroll", the element used as the scrollable area (usually the element ),

Add the `data-bs-target` attribute with a value of the navigation bar's ID or class.navbar name ( ). This ensures that the navigation bar is connected to a scrollable area.

Note that the scrollable elements must match the IDs of the links in each item in the navigation bar list ( match ).

The optional attribute data-bs-offsetspecifies the number of pixels offset from top to bottom when calculating scroll position. This is useful when you find that links within the navigation bar change their active state too early when switching to scrollable elements. The default is 10 pixels.

 

Relative positioning is required: The element needs the CSS ` position`data-bs-spy="scroll" property , with a value of "relative" to function correctly.

For example:

 Bootstrap Example 

Part 1

Introducing TipsMake.com: Originally a website providing knowledge about networks, servers, network devices, and computer tips, TipsMake.com has now become a social network for science and technology, expanding its content to meet the needs of its members in many more technology fields such as phones, smart devices, electronics, computer security, and more.

We want our members to always be up-to-date with the latest information, knowledge, and technological trends, as well as to be able to troubleshoot any technological problems they encounter when using computers, phones, and other common electronic devices.

Part 2

You can become a part of TipsMake.com by submitting articles and your technology experiences to the social media content management team via email, or by registering an account and posting directly on TipsMake.com.

You can become a part of TipsMake.com by submitting articles and your technology experiences to the social media content management team via email, or by registering an account and posting directly on TipsMake.com.

Part 3

TipsMake.com, a social network covering technology, science, and life topics, is developed and provided by META Online Network Joint Stock Company.

 

You will get the result as shown in the image below. Pay attention to your mouse scroll and look at the navigation menu bar as you scroll to clearly see the change.

Above is everything you need to know about how to create Scrollspy using Bootstrap 5. Hopefully, this Bootstrap 5 tutorial is helpful to you.

Related posts
Other Program articles
  • Lesson 26: Toast in Bootstrap 5

    toast cũng là một thành phần thú vị, giống như thông báo trên web, ứng dụng. dưới đây là cách tạo toast trong bootstrap 5.
  • Lesson 25: Popovers in Bootstrap 5

    popover cũng là một thành phần quan trọng trên web, ứng dụng. dưới đây là cách tạo popover trong bootstrap 5.
  • Lesson 24: Tooltips in Bootstrap 5

    tooltip là một box pop-up nhỏ, hiện ra khi người dùng di chuyển con trỏ chuột qua một nhân tố trên giao diện. dưới đây là cách tạo tooltip trong bootstrap 5.
  • Lesson 23: Modals in Bootstrap 5

    modal trong bootstrap 5 là thành phần hiện cửa sổ popup ở phía trên trang hiện tại. dưới đây là cách tạo hộp thoại hay popup bằng bootstrap 5.
  • Lesson 22: Carousel in Bootstrap 5

    carousel trong bootstrap 5 là một plugin được dùng để duyệt các phần tử như slide, ảnh… dưới đây là cách dùng carousel trong bootstrap 5.
  • Lesson 20: Navs in Bootstrap 5

    navs trong bootstrap 5 là thành phần giúp bạn thiết kế cách điều hướng trên web, ứng dụng hoặc phần mềm. dưới đây là cách dùng navs trong bootstrap 5.
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup