<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0"
>
<
title
>Bootstrap 5 Toast with Scroll Trigger</
title
>
<
link
href
=
rel
=
"stylesheet"
>
<
script
src
=
</
script
>
</
head
>
<
body
>
<
div
class
=
"position-fixed bottom-0 start-0 p-3"
style
=
"z-index: 11"
>
<
div
class
=
"toast"
role
=
"alert"
aria-live
=
"assertive"
aria-atomic
=
"true"
data-bs-autohide
=
"false"
style
=
"background-color:green; color: #fff;"
>
<
div
class
=
"toast-body"
>
You have scrolled down!
</
div
>
</
div
>
</
div
>
<
div
style
=
"height: 2000px;"
>
<
p
>
HTML stands for HyperText Markup Language. It creates a
complete website structure of web pages. HTML is a
combination of Hypertext and Markup language. Hypertext
defines the link between the web pages and markup language
defines the text document within the tag. This HTML Tutorial
provides basic to advanced concepts for beginners and
professionals. HTML is a markup language used by the browser
to manipulate text, images, and other content, in order to
display it in the required format. HTML was created by Tim
Berners-Lee in 1991. The first-ever version of HTML was HTML
1.0, but the first standard version was HTML 2.0, published
in 1995. The HTML heading tag is used to define the headings
of a page. There are six levels of headings defined by HTML.
These 6 heading elements are h1, h2, h3, h4, h5, and h6; with
h1 being the highest level and h6 being the least. Search
Engines use headings for indexing the structure and organizing
the content of the webpage. Headings are used for highlighting
important topics. They provide valuable information and tell
us about the structure of the document.The tag which stands for
the horizontal rule is used to define a thematic break in an HTML
page. The tag is an empty tag, and it does not require any end tag.
It is basically used to separate content. Please refer to the HTML
Tag article for more detailed information.
</
p
>
</
div
>
<
script
>
// JavaScript to show toast when scrolling down
window.addEventListener('scroll', function () {
var scrollPosition = window.scrollY;
// Adjust as needed, this is the scroll position
// where the toast will appear
var triggerPosition = 200;
var toastElement = document.querySelector('.toast');
var toast = new bootstrap.Toast(toastElement);
if (scrollPosition > triggerPosition) {
toast.show();
} else {
// Hide the toast when scrolling back to the top
toast.hide();
}
});
</
script
>
</
body
>
</
html
>