Courses /
Bootstrap: Building Stylish Websites
Building the Header Navigation
1. Create a Navigation Bar
Start by adding a navigation bar at the top of the page. Use Bootstrap's Navbar component for this purpose.
Code Description
-
Navbar Structure: Utilizes Bootstrap classes such as
navbar
,navbar-expand-lg
,navbar-light
, andbg-light
to create a navigation bar with responsive behavior and light background color. -
Branding:
<a>
tag with the classnavbar-brand
is used to represent the branding or logo of the website within the navigation bar, styled by Bootstrap to maintain consistency. -
Toggle Button:
-
<button>
with the classnavbar-toggler
creates a toggle button for collapsing and expanding the navigation menu on smaller screens. -
data-bs-toggle="collapse"
: Specifies the behavior of the button to toggle the collapse state of the target element. -
data-bs-target="#navbarSupportedContent"
: Defines the target element to be collapsed or expanded, in this case, the collapsible content of the navigation bar.
-
-
Collapsible Content:
<div>
with classescollapse
andnavbar-collapse
, along with the unique IDnavbarSupportedContent
, contains collapsible content of the navigation bar, making use of Bootstrap's collapse feature. -
Navigation Links Container:
<ul>
with classesnavbar-nav
andms-auto
forms an unordered list to hold the navigation links, styled by Bootstrap to resemble a navigation menu and align links to the right (ms-auto
).
2. Add Navigation Links
Within the navbar-nav
class, add navigation links for the homepage, about me, experience, skills, and contact sections.
Code Description
-
Navigation Link Items:
<li>
elements with the classnav-item
represent individual items within the navigation menu. -
Navigation Links:
-
<a>
tags with the classnav-link
represent the navigation links within each list item. -
Each link has an
href
attribute pointing to a specific section of the webpage indicated by the hash symbol followed by the section's ID (e.g.,#about
,#experience
,#skills
,#contact
).
-
Result
index.html
index.css
index.js
Everything was clear?
Section 5. Chapter 3
Course Content
Bootstrap: Building Stylish Websites
1. Understanding Bootstrap
2. Setting Up Environment
4. Advanced Concepts
Bootstrap: Building Stylish Websites
Building the Header Navigation
1. Create a Navigation Bar
Start by adding a navigation bar at the top of the page. Use Bootstrap's Navbar component for this purpose.
Code Description
-
Navbar Structure: Utilizes Bootstrap classes such as
navbar
,navbar-expand-lg
,navbar-light
, andbg-light
to create a navigation bar with responsive behavior and light background color. -
Branding:
<a>
tag with the classnavbar-brand
is used to represent the branding or logo of the website within the navigation bar, styled by Bootstrap to maintain consistency. -
Toggle Button:
-
<button>
with the classnavbar-toggler
creates a toggle button for collapsing and expanding the navigation menu on smaller screens. -
data-bs-toggle="collapse"
: Specifies the behavior of the button to toggle the collapse state of the target element. -
data-bs-target="#navbarSupportedContent"
: Defines the target element to be collapsed or expanded, in this case, the collapsible content of the navigation bar.
-
-
Collapsible Content:
<div>
with classescollapse
andnavbar-collapse
, along with the unique IDnavbarSupportedContent
, contains collapsible content of the navigation bar, making use of Bootstrap's collapse feature. -
Navigation Links Container:
<ul>
with classesnavbar-nav
andms-auto
forms an unordered list to hold the navigation links, styled by Bootstrap to resemble a navigation menu and align links to the right (ms-auto
).
2. Add Navigation Links
Within the navbar-nav
class, add navigation links for the homepage, about me, experience, skills, and contact sections.
Code Description
-
Navigation Link Items:
<li>
elements with the classnav-item
represent individual items within the navigation menu. -
Navigation Links:
-
<a>
tags with the classnav-link
represent the navigation links within each list item. -
Each link has an
href
attribute pointing to a specific section of the webpage indicated by the hash symbol followed by the section's ID (e.g.,#about
,#experience
,#skills
,#contact
).
-
Result
index.html
index.css
index.js
Everything was clear?
Section 5. Chapter 3