How to Create Scroll Bar Indicators By Using HTML, CSS & JS.
This tutorial will guide you through Creating a Scroll Bar Indicators By Using HTML, CSS & JS. Follow all the given step :
Step 1 : Create Index.html and add given html code on it.
Step 2 : Create style.css and add given css code on it.
Step 3 : Create index.js and add given JavaScript code on it.
HTML
HTML Code for Scroll Bar Indicators.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="header">
<h2>Scroll Bar Indicator</h2>
<div class="container">
<div class="bar" id="mybar"></div>
</div>
</div>
<div class="main"></div>
</body>
</html>
CSS
CSS Code for Scroll Bar Indicators.
body{
margin: 0;
font-size: 25px;
font-family: serif;
background: #000;
color: white;
}
.header{
position: fixed;
top: 0;
z-index: 1;
width: 100%;
background: rgb(52,52,52);
box-shadow: 0px 1px 0px 0px rgb(255,0,0);
height: 60px;
}
.header h2{
text-align: center;
font-size: 20px;
font-style: italic;
color: #fff;
}
.container{
width: 100%;
height: 4px;
background: #ffffff;
}
.bar{
height: 4px;
background-color: rgb(255,0,0);
box-shadow: 2px 2px 31px 2px red;
width: 0%;
}
.content{
padding: 100px 0;
margin: 50px auto 0 auto;
width: 80%;
}
.main{
height: 3000px;
}
JavaScript
JavaScript code for Scroll Bar Indicators.
window.onscroll = function() {myfunction()};
function myfunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("mybar").style.width = scrolled + "%";
}
What is HTML
HTML, or HyperText Markup Language, is the standard markup language used to create and design documents on the World Wide Web. It's essentially the backbone of web pages, providing the structure and content that web browsers interpret and display.
HTML consists of a series of elements, which are enclosed by tags to define their purpose and function on a webpage. These elements can include headings, paragraphs, images, links, lists, forms, and more. By using a combination of HTML elements, web developers can organize and present information in a structured and visually appealing manner.
HTML is not a programming language but rather a markup language. This means it doesn't have the capability to perform calculations or execute complex logic like programming languages do. Instead, HTML focuses on describing the structure and content of a document, leaving the presentation and functionality to other technologies like CSS (Cascading Style Sheets) for styling and JavaScript for interactivity.
In summary, HTML serves as the foundation for building web pages, providing the structure and content necessary for browsers to render and display information to users on the internet.
What is CSS
CSS, or Cascading Style Sheets, is a language used to style the presentation of web documents written in HTML and XML. It provides a way to control the layout, colors, fonts, and other visual aspects of a webpage, enabling developers to create attractive and responsive designs. By separating content from presentation, CSS promotes cleaner code, easier maintenance, and greater flexibility in website design. With CSS, developers can achieve consistent branding, improved user experience, and better accessibility across various devices and screen sizes.
What is JavaScript
JavaScript is a versatile programming language used for creating dynamic and interactive web content. It enables developers to manipulate HTML elements, respond to user actions, and build seamless web applications. With its extensive ecosystem of libraries and frameworks, JavaScript powers both client-side and server-side development, making it an essential tool for modern web development.