SlideShare a Scribd company logo
Learn Bootstrap 4 in 30 minutes by building a
landing page website
A guide for beginners
“Bootstrap is a free, open-source front-end
library for designing websites and web
applications. It contains HTML- and CSS-
based design templates for everything from
typography, forms, buttons, navigation and
other interface components as well as
JavaScript extensions. Unlike many other web
frameworks, Bootstrap concerns itself with
front-end development only.” — Wikipedia
There are many versions of Bootstrap with version 4 being the
latest. In this article, we are going to build a website using
Bootstrap 4.
Prerequisites
Before starting, there are some skills you’ll have to know in order
to learn and use the Bootstrap framework:
 HTML fundamentals
 basic knowledge of CSS
 and some basic JQuery
Table of Contents
We will cover the topics below while building the website:
 Downloading and installing Bootstrap 4
 The new features of Bootstrap 4
 Bootstrap Grid system
 Navbar
 Header
 Buttons
 About Section
 Portfolio Section
 Blog Section
 Cards
 Team Section
 Contact Form
 Fonts
 Scroll Effect
 Wrap-up and Conclusion
Downloading and installing Bootstrap
4
There are three ways to install and include Bootstrap 4 for your
project:
1. Use npm
You can install Bootstrap 4 by running this command npm install
bootstrap
2. Use a Content Delivery Network (CDN)
By including this link in your project between head tags:
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-
Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
3. Download the Bootstrap 4 library and use it locally.
The structure of our project should look like this:
The new features of Bootstrap 4
What’s new in Bootstrap 4? And what’s different between
Bootstrap 3 and 4?
Bootstrap 4 now comes with some awesome features that didn’t
exist in the last version:
 Bootstrap 4 is written using Flexbox Grid, whereas Bootstrap 3
was written using the float method.
 Bootstrap 4 uses rem CSS units whereas Bootstrap 3 uses px.
See how these two units differ.
 Panels, thumbnails, and wells have been dropped entirely.
You can read in detail more about the global changes and
removed features of Bootstrap 4 here.
Without jumping too deep into detail here, let’s move on to some
other important things.
The Bootstrap Grid system
The Bootstrap Grid system helps you to create your layout and
easily build a responsive website. There have not been any changes
in the class names, except the .xs class, which no longer exists in
Bootstrap 4.
The grid is divided into 12 columns, so your layout will be based on
this.
To use the grid system you’ll have to add a .row class to the
main div.
col-lg-2 // class used for large devices like laptops
col-md-2 // class used for medium devices like tablets
col-sm-2// class used for small devices like mobile phones
Navbar
The navbar wrapper is pretty cool in Bootstrap 4. It’s so helpful
when it comes to building a responsive navbar.
To get it, we are going to add the navbar class to our index.html file:
<!-- navbar -->
<nav class="navbar navbar-expand-lg fixed-top ">
<a class="navbar-brand" href="#">Home</a>
<button class="navbar-toggler" type="button" data-
toggle="collapse" data-target="#navbarSupportedContent" aria-
controls="navbarSupportedContent" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse "
id="navbarSupportedContent"> <ul class="navbar-nav mr-4">
<li class="nav-item">
<a class="nav-link" data-value="about" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link " data-
value="portfolio"href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="blog" href="#">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="team" href="#">
Team</a> </li>
<li class="nav-item">
<a class="nav-link " data-value="contact" href="#">Contact</a>
</li>
</ul>
</div></nav>
Create and include a main.css file so that you can customize the
CSS style.
Put this within the head tag in your index.html file:
<link rel="stylesheet" type="text/css" href="css/main.css">
Let’s add some colors to our navbar:
.navbar{ background:#F97300;}
.nav-link , .navbar-brand{ color: #f4f4f4; cursor: pointer;}
.nav-link{ margin-right: 1em !important;}
.nav-link:hover{ background: #f4f4f4; color: #f97300; }
.navbar-collapse{ justify-content: flex-end;}
.navbar-toggler{ background:#fff !important;}
The new Bootstrap Grid is built with the Flexbox system, so for
alignment, you have to use a Flexbox property. For example, to
place the navbar menu on the right we need to add a justify-
content property and set it to flex-end.
.navbar-collapse{
justify-content: flex-end;
}
Add the .fixed-top class to the navbar to give it a fixed position.
To make the navbar background color light, add .bg-light. For a
dark background, add .bg-dark, and for a light blue background,
add
.bg-primary.
Here’s how that should look:
.bg-dark{
background-color:#343a40!important
}
.bg-primary{
background-color:#007bff!important
}
Header
<header class="header">
</header>
Let’s try and create a layout for the header.
Here, we want to make sure the header takes up the window’s
height so we are going to use a little JQuery code.
First, create a file named main.js and include it in
the index.html file before the closing body tag:
<script type="text/javascript" src='js/main.js'></script>
In the main.js file insert this a little code of JQuery:
$(document).ready(function(){
$('.header').height($(window).height());
})
It’d be pretty cool if we set a nice background image to the header:
/*header style*/
.header{
background-image: url('../images/headerback.jpg');
background-attachment: fixed;
background-size: cover;
background-position: center;
}
Let’s add an overlay to make the header look a bit more
professional:
Add this to your index.html file:
<header class="header">
<div class="overlay"></div>
</header>
Then, add this to your main.css file:
.overlay{
position: absolute;
min-height: 100%;
min-width: 100%;
left: 0;
top: 0;
background: rgba(244, 244, 244, 0.79);
}
Now we have to add a description inside the header.
To wrap our description we’re first going to create a div and give it
a class .container.
.container is a Bootstrap class that will help you to wrap your
content and make your layout more responsive:
<header class="header">
<div class="overlay"></div>
<div class="container">
</div>
</header>
Then, add another div which will contain the description.
<div class="description ">
<h1> Hello ,Welcome To My official Website
<p> cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</p>
<button class="btn btn-outline-secondary btn-lg">See
more</button> </h1>
</div>
We’ll give it a class of .description and add the .text-center class
to make sure the content is placed in the center of the page.
Buttons
Add the class .btn btn-outline-secondary to the button element.
there are many other Bootstrap classes for buttons.
Check some examples:
CodePen Embed — buttons in Bootstrap 4
Buttons Button primary Button default Button danger Button info Button warning
Button dark Button success Buttons…codepen.io
Here’s how the styling for the .description looks in
the main.css file:
.description{
position: absolute;
top: 30%;
margin: auto;
padding: 2em;
}
.description h1{
color:#F97300 ;
}
.description p{
color:#666;
font-size: 20px;
width: 50%;
line-height: 1.5;
}
.description button{
border:1px solid #F97300;
background:#F97300;
color:#fff;
}
After all of that, our header will look like this:
Cool isn’t :).
About Section
In this section, we will use some Bootstrap Grid to divide the
section into two parts.
To start our grid, we have to assign the .row class to the parent div.
<div class="row"></div>
The first section will be on the left and will contain a picture, the
second section will be on the right and contain a description.
Each div will take up 6 columns — that means half of the section.
Remember that a grid is divided into 12 columns.
In the first div on the left side:
<div class="row">
// left side
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/team-3.jpg" class="img-fluid">
<span class="text-justify">S.Web Developer</span>
</div>
</div>
After adding the the HTML elements on the right-side, the
structure of the code will look like this:
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/team-3.jpg" class="img-fluid">
<span class="text-justify">S.Web Developer</span>
</div>
<div class="col-lg-8 col-md-8 col-sm-12 desc">
<h3>D.John</h3>
<p>
ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in
voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.
</p>
</div>
</div>
Here’s how I’ve made it look:
.about{
margin: 4em 0;
padding: 1em;
position: relative;
}
.about h1{
color:#F97300;
margin: 2em;
}
.about img{
height: 100%;
width: 100%;
border-radius: 50%
}
.about span{
display: block;
color: #888;
position: absolute;
left: 115px;
}
.about .desc{
padding: 2em;
border-left:4px solid #10828C;
}
.about .desc h3{
color: #10828C;
}
.about .desc p{
line-height:2;
color:#888;
}
Portfolio Section
Now, let’s move onto the next bit and make a portfolio section that
will contain a gallery.
The structure of our HTML code for the Portfolio section looks like
this:
<!-- portfolio -->
<div class="portfolio">
<h1 class="text-center">Portfolio</h1>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port13.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port1.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port6.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port3.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port11.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/electric.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/Classic.jpg" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port1.png" class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="images/portfolio/port8.png" class="img-fluid">
</div>
</div>
</div>
</div>
Adding .img-fluid to each image to makes it responsive.
Each item in our gallery will take up 4 columns (remember, col-
md-4 for medium devices, col-lg-4 for large devices). That’s equal
to 33.33333% on large devices such desktops and large tablets,
and 12 columns on a small device (like iPhone, mobile devices) will
take up 100% of the container.
Let’s add some styling to our Gallery:
/*Portfolio*/
.portfolio{
margin: 4em 0;
position: relative;
}
.portfolio h1{
color:#F97300;
margin: 2em;
}
.portfolio img{
height: 15rem;
width: 100%;
margin: 1em;
}
Blog Section
Cards
Cards in Bootstrap 4 make blog design so much easier. The cards
are appropriate for articles and posts.
To create a card, we use the class .card and assign it to
a div element,
The card class contains many features:
 .card-header: define the card header
 .card-body: for the card body
 .card-title: the title of the card
 card-footer: define the footer of the card.
 .card-image: for the card’s image
So, our website’s HTML should now look something like this:
<!-- Posts section -->
<div class="blog">
<div class="container">
<h1 class="text-center">Blog</h1>
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12">
<div class="card">
<div class="card-img">
<img src="images/posts/polit.jpg" class="img-fluid">
</div>
<div class="card-body">
<h4 class="card-title">Post Title</h4>
<p class="card-text">
proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.
</p>
</div>
<div class="card-footer">
<a href="" class="card-link">Read more</a>
</div>
</div>
</div>
<div class="col-md-4 col-lg-4 col-sm-12">
<div class="card">
<div class="card-img">
<img src="images/posts/images.jpg" class="img-fluid">
</div>
<div class="card-body">
<h4 class="card-title">Post Title</h4>
<p class="card-text">
proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.
</p>
</div>
<div class="card-footer">
<a href="" class="card-link">Read more</a>
</div>
</div>
</div>
<div class="col-md-4 col-lg-4 col-sm-12">
<div class="card">
<div class="card-img">
<img src="images/posts/imag2.jpg" class="img-fluid">
</div>
<div class="card-body">
<h4 class="card-title">Post Title</h4>
<p class="card-text">
proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.
</p>
</div>
<div class="card-footer">
<a href="" class="card-link">Read more</a>
</div>
</div>
</div>
</div>
</div>
</div>
We need to add some CSS style to the cards:
.blog{
margin: 4em 0;
position: relative;
}
.blog h1{
color:#F97300;
margin: 2em;
}
.blog .card{
box-shadow: 0 0 20px #ccc;
}
.blog .card img{
width: 100%;
height: 12em;
}
.blog .card-title{
color:#F97300;
}
.blog .card-body{
padding: 1em;
}
After adding the Blog section to our website, the design should
now look something like this:
ViA Bootstrap 4
Cool isn’t it?  
Team Section
In this section we will use the grid system to distribute even space
between images. Each image takes up 3 columns (.col-md-3) of the
container — that equals 25% of the total space.
Our HTML structure:
<!-- Team section -->
<div class="team">
<div class="container">
<h1 class="text-center">Our Team</h1>
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-12 item">
<img src="images/team-2.jpg" class="img-fluid" alt="team">
<div class="des">
Sara
</div>
<span class="text-muted">Manager</span>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 item">
<img src="images/team-3.jpg" class="img-fluid" alt="team">
<div class="des">
Chris
</div>
<span class="text-muted">S.enginner</span>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 item">
<img src="images/team-2.jpg" class="img-fluid" alt="team">
<div class="des">
Layla
</div>
<span class="text-muted">Front End Developer</span>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 item">
<img src="images/team-3.jpg" class="img-fluid" alt="team">
<div class="des">
J.Jirard
</div>
<span class="text-muted">Team Manger</span>
</div>
</div>
</div>
</div>
And let’s add some style:
.team{
margin: 4em 0;
position: relative;
}
.team h1{
color:#F97300;
margin: 2em;
}
.team .item{
position: relative;
}
.team .des{
background: #F97300;
color: #fff;
text-align: center;
border-bottom-left-radius: 93%;
transition:.3s ease-in-out;
}
Adding an overlay to the image on-hover using animation would
be nice  .
To make this effect , add the styles below to main.css file:
.team .item:hover .des{
height: 100%;
background:#f973007d;
position: absolute;
width: 89%;
padding: 5em;
top: 0;
border-bottom-left-radius: 0;
}
Super cool!  
Contact Form
The Contact Form is the last section to add, then we are done  .
The Contact Form section will contain a form through which
visitors can send an email or give feedback. We will use some
Bootstrap classes to make the design beautiful and responsive.
Like Bootstrap 3, Bootstrap 4 also uses the .form-control class for
input fields, but there are some new features added — like
switching from .input-group-addon (deprecated) to .input-group-
prepend (to use icons as labels ).
See Bootstrap 4 document for more information. In our Contact
form we will wrap each input between a div that has the
class .form-group.
The index.html file now looks something like this:
<!-- Contact form -->
<div class="contact-form">
<div class="container">
<form>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<h1>Get in Touch</h1>
</div>
<div class="col-lg-8 col-md-8 col-sm-12 right">
<div class="form-group">
<input type="text" class="form-control form-control-lg"
placeholder="Your Name" name="">
</div>
<div class="form-group">
<input type="email" class="form-control form-control-
lg" placeholder="YourEmail@email.com" name="email">
</div>
<div class="form-group">
<textarea class="form-control form-control-lg">
</textarea>
</div>
<input type="submit" class="btn btn-secondary btn-block"
value="Send" name="">
</div>
</div>
</form>
</div>
</div>
Contact section’styles :
main.css
.contact-form{
margin: 6em 0;
position: relative;
}
.contact-form h1{
padding:2em 1px;
color: #F97300;
}
.contact-form .right{
max-width: 600px;
}
.contact-form .right .btn-secondary{
background: #F97300;
color: #fff;
border:0;
}
.contact-form .right .form-control::placeholder{
color: #888;
font-size: 16px;
}
Fonts
I think default fonts are ugly so we are going to use the Google
Font API, and we’ll choose Raleway which is a nice font and
appropriate to our template.
Add this link into your main.css file:
@import url('https://fonts.googleapis.com/css?family=Raleway');
and set the global style to HTML and heading tags:
html,h1,h2,h3,h4,h5,h6,a{
font-family: "Raleway";
}
Scroll Effect
The last thing missing is scroll effect. Here, we’ll have to use some
JQuery. Don’t worry  if you are not familiar with it, just add this
code into yourmain.js file:
$(".navbar a").click(function(){
$("body,html").animate({
scrollTop:$("#" + $(this).data('value')).offset().top
},1000)
})
and add a data-value attribute to each navbar link:
<li class="nav-item">
<a class="nav-link" data-value="about"
href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="portfolio"
href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="blog"
href="#">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="team" href="#">
Team</a>
</li>
<li class="nav-item">
<a class="nav-link " data-value="contact"
href="#">Contact</a>
</li>
Set an id attribute to each section.
Note: The id must be identical to the data-value attribute in the
navbar link for the scroll to work:
<div class="about" id="about"></div>
Wrap-up and Conclusion
Bootstrap 4 is a great option for building your web application. It
delivers high quality of UI elements and it’s easy to customize,
integrate and use. It will also help you to include responsiveness in
your website, therefore delivering a premium user experience to
your users.
You will find the project’s files on GitHub.
Prepared By : ViASTUDY
Source: medium.freecodecamp.org

More Related Content

PPTX
Bootstrap [part 2]
PDF
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
PPT
WordPress 2.5 Overview - Rich Media Institute
PDF
An Introduction To HTML5
PDF
Modular HTML, CSS, & JS Workshop
PPTX
About Best friends - HTML, CSS and JS
PPS
Bootstrap 3 vs. bootstrap 4
PDF
HTML5 & CSS3 Flag
Bootstrap [part 2]
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
WordPress 2.5 Overview - Rich Media Institute
An Introduction To HTML5
Modular HTML, CSS, & JS Workshop
About Best friends - HTML, CSS and JS
Bootstrap 3 vs. bootstrap 4
HTML5 & CSS3 Flag

What's hot (20)

PDF
Using Core Themes in Drupal 8
PPTX
Introduction to HTML5
PPTX
Introduction to Bootstrap
PDF
Bootstrap 4 Tutorial PDF for Beginners - Learn Step by Step
PDF
WordPress Theme Structure
PPTX
Custom WordPress theme development
KEY
HTML CSS & Javascript
PDF
Mobile themes, QR codes, and shortURLs
PDF
Architecting with Style
PDF
PDF
integrasi template admin lte terbaru dengan laravel 7
PPTX
Bootstrap - Web Development Framework
ZIP
Theme Kickstart
PDF
HTML5 Essentials
PDF
Installing And Configuration for your Wordpress blog
KEY
Building a Mobile Drupal Site
PDF
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
PDF
[O'Reilly] HTML5 Design
PPTX
Bootstrap [part 1]
PPTX
Customizing WordPress Themes
Using Core Themes in Drupal 8
Introduction to HTML5
Introduction to Bootstrap
Bootstrap 4 Tutorial PDF for Beginners - Learn Step by Step
WordPress Theme Structure
Custom WordPress theme development
HTML CSS & Javascript
Mobile themes, QR codes, and shortURLs
Architecting with Style
integrasi template admin lte terbaru dengan laravel 7
Bootstrap - Web Development Framework
Theme Kickstart
HTML5 Essentials
Installing And Configuration for your Wordpress blog
Building a Mobile Drupal Site
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
[O'Reilly] HTML5 Design
Bootstrap [part 1]
Customizing WordPress Themes
Ad

Similar to ViA Bootstrap 4 (20)

PPTX
Intro to Bootstrap
PPTX
Module 3 - Intro to Bootstrap
PPTX
Lecture-10.pptx
PPT
Twitter bootstrap (css, components and javascript)
PPTX
Bootstrap
PDF
Bootstrap notes on developing basic website by Likith.pdf
PPTX
Lecture-03.pptx
PPTX
Bootstrap
PPTX
Bootstrap SLIDES for web development course
PPT
Twitter bootstrap training_session_ppt
PPTX
Boot strap
PDF
Introduction to Bootstrap
PPT
Responsive web design
PPTX
An introduction to bootstrap
PPT
Introduction to BOOTSTRAP
PDF
Bootstrap for webtechnology_data science.pdf
PDF
Bootstrap 3 Cheat Sheet PDF Reference
PDF
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
PPTX
Using Bootstrap to Make Accessible Front-Ends(2).pptx
PPTX
Using Bootstrap to Make Accessible Front-Ends(2).pptx
Intro to Bootstrap
Module 3 - Intro to Bootstrap
Lecture-10.pptx
Twitter bootstrap (css, components and javascript)
Bootstrap
Bootstrap notes on developing basic website by Likith.pdf
Lecture-03.pptx
Bootstrap
Bootstrap SLIDES for web development course
Twitter bootstrap training_session_ppt
Boot strap
Introduction to Bootstrap
Responsive web design
An introduction to bootstrap
Introduction to BOOTSTRAP
Bootstrap for webtechnology_data science.pdf
Bootstrap 3 Cheat Sheet PDF Reference
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Using Bootstrap to Make Accessible Front-Ends(2).pptx
Using Bootstrap to Make Accessible Front-Ends(2).pptx
Ad

More from imdurgesh (20)

PDF
Azure quick-start-for-net-developers
PDF
Sales Negotiating-for-entrepreneurs
PDF
Automated testing-whitepaper
PDF
Visual studio-2019-succinctly
PPTX
C# and .net framework
PDF
30 days-of-react-ebook-fullstackio
PDF
Linq pad succinctly
PDF
The road-to-learn-react
PDF
Public speaking for_geeks_succinctly
PDF
Google maps api_succinctly
PDF
W3 css succinctly
PDF
Aspnet core-2-succinctly
PDF
Cryptography in net_succinctly
PDF
Azure functions-succinctly
PDF
Nodejs succinctly
PDF
Angular succinctly
PDF
Reactjs succinctly
PDF
C sharp code_contracts_succinctly
PDF
Asp.net tutorial
PDF
Performance and Evaluations of Websites
Azure quick-start-for-net-developers
Sales Negotiating-for-entrepreneurs
Automated testing-whitepaper
Visual studio-2019-succinctly
C# and .net framework
30 days-of-react-ebook-fullstackio
Linq pad succinctly
The road-to-learn-react
Public speaking for_geeks_succinctly
Google maps api_succinctly
W3 css succinctly
Aspnet core-2-succinctly
Cryptography in net_succinctly
Azure functions-succinctly
Nodejs succinctly
Angular succinctly
Reactjs succinctly
C sharp code_contracts_succinctly
Asp.net tutorial
Performance and Evaluations of Websites

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
web development for engineering and engineering
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
composite construction of structures.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
additive manufacturing of ss316l using mig welding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Lecture Notes Electrical Wiring System Components
web development for engineering and engineering
OOP with Java - Java Introduction (Basics)
Embodied AI: Ushering in the Next Era of Intelligent Systems
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Lesson 3_Tessellation.pptx finite Mathematics
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Construction Project Organization Group 2.pptx
composite construction of structures.pdf
Geodesy 1.pptx...............................................
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CYBER-CRIMES AND SECURITY A guide to understanding
Arduino robotics embedded978-1-4302-3184-4.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
additive manufacturing of ss316l using mig welding

ViA Bootstrap 4

  • 1. Learn Bootstrap 4 in 30 minutes by building a landing page website A guide for beginners “Bootstrap is a free, open-source front-end library for designing websites and web applications. It contains HTML- and CSS- based design templates for everything from typography, forms, buttons, navigation and other interface components as well as JavaScript extensions. Unlike many other web
  • 2. frameworks, Bootstrap concerns itself with front-end development only.” — Wikipedia There are many versions of Bootstrap with version 4 being the latest. In this article, we are going to build a website using Bootstrap 4. Prerequisites Before starting, there are some skills you’ll have to know in order to learn and use the Bootstrap framework:  HTML fundamentals  basic knowledge of CSS  and some basic JQuery Table of Contents We will cover the topics below while building the website:  Downloading and installing Bootstrap 4  The new features of Bootstrap 4  Bootstrap Grid system  Navbar  Header
  • 3.  Buttons  About Section  Portfolio Section  Blog Section  Cards  Team Section  Contact Form  Fonts  Scroll Effect  Wrap-up and Conclusion Downloading and installing Bootstrap 4 There are three ways to install and include Bootstrap 4 for your project: 1. Use npm You can install Bootstrap 4 by running this command npm install bootstrap 2. Use a Content Delivery Network (CDN) By including this link in your project between head tags: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
  • 4. integrity="sha384- Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> 3. Download the Bootstrap 4 library and use it locally. The structure of our project should look like this: The new features of Bootstrap 4 What’s new in Bootstrap 4? And what’s different between Bootstrap 3 and 4?
  • 5. Bootstrap 4 now comes with some awesome features that didn’t exist in the last version:  Bootstrap 4 is written using Flexbox Grid, whereas Bootstrap 3 was written using the float method.  Bootstrap 4 uses rem CSS units whereas Bootstrap 3 uses px. See how these two units differ.  Panels, thumbnails, and wells have been dropped entirely. You can read in detail more about the global changes and removed features of Bootstrap 4 here. Without jumping too deep into detail here, let’s move on to some other important things. The Bootstrap Grid system The Bootstrap Grid system helps you to create your layout and easily build a responsive website. There have not been any changes in the class names, except the .xs class, which no longer exists in Bootstrap 4. The grid is divided into 12 columns, so your layout will be based on this. To use the grid system you’ll have to add a .row class to the main div. col-lg-2 // class used for large devices like laptops col-md-2 // class used for medium devices like tablets col-sm-2// class used for small devices like mobile phones
  • 6. Navbar The navbar wrapper is pretty cool in Bootstrap 4. It’s so helpful when it comes to building a responsive navbar. To get it, we are going to add the navbar class to our index.html file: <!-- navbar --> <nav class="navbar navbar-expand-lg fixed-top "> <a class="navbar-brand" href="#">Home</a> <button class="navbar-toggler" type="button" data- toggle="collapse" data-target="#navbarSupportedContent" aria- controls="navbarSupportedContent" aria-expanded="false" aria- label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse " id="navbarSupportedContent"> <ul class="navbar-nav mr-4"> <li class="nav-item">
  • 7. <a class="nav-link" data-value="about" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link " data- value="portfolio"href="#">Portfolio</a> </li> <li class="nav-item"> <a class="nav-link " data-value="blog" href="#">Blog</a> </li> <li class="nav-item"> <a class="nav-link " data-value="team" href="#"> Team</a> </li> <li class="nav-item"> <a class="nav-link " data-value="contact" href="#">Contact</a> </li> </ul> </div></nav> Create and include a main.css file so that you can customize the CSS style. Put this within the head tag in your index.html file: <link rel="stylesheet" type="text/css" href="css/main.css"> Let’s add some colors to our navbar: .navbar{ background:#F97300;} .nav-link , .navbar-brand{ color: #f4f4f4; cursor: pointer;} .nav-link{ margin-right: 1em !important;} .nav-link:hover{ background: #f4f4f4; color: #f97300; } .navbar-collapse{ justify-content: flex-end;} .navbar-toggler{ background:#fff !important;} The new Bootstrap Grid is built with the Flexbox system, so for alignment, you have to use a Flexbox property. For example, to place the navbar menu on the right we need to add a justify- content property and set it to flex-end.
  • 8. .navbar-collapse{ justify-content: flex-end; } Add the .fixed-top class to the navbar to give it a fixed position. To make the navbar background color light, add .bg-light. For a dark background, add .bg-dark, and for a light blue background, add .bg-primary. Here’s how that should look: .bg-dark{ background-color:#343a40!important } .bg-primary{ background-color:#007bff!important } Header <header class="header"> </header> Let’s try and create a layout for the header. Here, we want to make sure the header takes up the window’s height so we are going to use a little JQuery code. First, create a file named main.js and include it in the index.html file before the closing body tag: <script type="text/javascript" src='js/main.js'></script> In the main.js file insert this a little code of JQuery:
  • 9. $(document).ready(function(){ $('.header').height($(window).height()); }) It’d be pretty cool if we set a nice background image to the header: /*header style*/ .header{ background-image: url('../images/headerback.jpg'); background-attachment: fixed; background-size: cover; background-position: center; } Let’s add an overlay to make the header look a bit more professional: Add this to your index.html file:
  • 10. <header class="header"> <div class="overlay"></div> </header> Then, add this to your main.css file: .overlay{ position: absolute; min-height: 100%; min-width: 100%; left: 0; top: 0; background: rgba(244, 244, 244, 0.79); } Now we have to add a description inside the header. To wrap our description we’re first going to create a div and give it a class .container. .container is a Bootstrap class that will help you to wrap your content and make your layout more responsive: <header class="header"> <div class="overlay"></div> <div class="container"> </div> </header> Then, add another div which will contain the description. <div class="description "> <h1> Hello ,Welcome To My official Website <p> cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <button class="btn btn-outline-secondary btn-lg">See more</button> </h1> </div>
  • 11. We’ll give it a class of .description and add the .text-center class to make sure the content is placed in the center of the page. Buttons Add the class .btn btn-outline-secondary to the button element. there are many other Bootstrap classes for buttons. Check some examples: CodePen Embed — buttons in Bootstrap 4 Buttons Button primary Button default Button danger Button info Button warning Button dark Button success Buttons…codepen.io Here’s how the styling for the .description looks in the main.css file: .description{ position: absolute; top: 30%; margin: auto; padding: 2em; } .description h1{ color:#F97300 ; } .description p{ color:#666; font-size: 20px; width: 50%; line-height: 1.5; } .description button{ border:1px solid #F97300; background:#F97300; color:#fff; } After all of that, our header will look like this:
  • 13. About Section In this section, we will use some Bootstrap Grid to divide the section into two parts. To start our grid, we have to assign the .row class to the parent div. <div class="row"></div> The first section will be on the left and will contain a picture, the second section will be on the right and contain a description. Each div will take up 6 columns — that means half of the section. Remember that a grid is divided into 12 columns. In the first div on the left side: <div class="row"> // left side <div class="col-lg-4 col-md-4 col-sm-12">
  • 14. <img src="images/team-3.jpg" class="img-fluid"> <span class="text-justify">S.Web Developer</span> </div> </div> After adding the the HTML elements on the right-side, the structure of the code will look like this: <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/team-3.jpg" class="img-fluid"> <span class="text-justify">S.Web Developer</span> </div> <div class="col-lg-8 col-md-8 col-sm-12 desc"> <h3>D.John</h3> <p> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> </div> Here’s how I’ve made it look: .about{ margin: 4em 0; padding: 1em; position: relative; } .about h1{
  • 15. color:#F97300; margin: 2em; } .about img{ height: 100%; width: 100%; border-radius: 50% } .about span{ display: block; color: #888; position: absolute; left: 115px; } .about .desc{ padding: 2em; border-left:4px solid #10828C; } .about .desc h3{ color: #10828C; } .about .desc p{ line-height:2; color:#888; }
  • 16. Portfolio Section Now, let’s move onto the next bit and make a portfolio section that will contain a gallery. The structure of our HTML code for the Portfolio section looks like this: <!-- portfolio --> <div class="portfolio"> <h1 class="text-center">Portfolio</h1> <div class="container"> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port13.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port1.png" class="img-fluid"> </div>
  • 17. <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port6.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port3.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port11.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/electric.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/Classic.jpg" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port1.png" class="img-fluid"> </div> <div class="col-lg-4 col-md-4 col-sm-12"> <img src="images/portfolio/port8.png" class="img-fluid"> </div> </div> </div> </div> Adding .img-fluid to each image to makes it responsive. Each item in our gallery will take up 4 columns (remember, col- md-4 for medium devices, col-lg-4 for large devices). That’s equal to 33.33333% on large devices such desktops and large tablets, and 12 columns on a small device (like iPhone, mobile devices) will take up 100% of the container. Let’s add some styling to our Gallery: /*Portfolio*/ .portfolio{ margin: 4em 0; position: relative; } .portfolio h1{ color:#F97300; margin: 2em; }
  • 18. .portfolio img{ height: 15rem; width: 100%; margin: 1em; } Blog Section Cards Cards in Bootstrap 4 make blog design so much easier. The cards are appropriate for articles and posts. To create a card, we use the class .card and assign it to a div element, The card class contains many features:  .card-header: define the card header
  • 19.  .card-body: for the card body  .card-title: the title of the card  card-footer: define the footer of the card.  .card-image: for the card’s image So, our website’s HTML should now look something like this: <!-- Posts section --> <div class="blog"> <div class="container"> <h1 class="text-center">Blog</h1> <div class="row"> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img src="images/posts/polit.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img src="images/posts/images.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  • 20. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> <div class="col-md-4 col-lg-4 col-sm-12"> <div class="card"> <div class="card-img"> <img src="images/posts/imag2.jpg" class="img-fluid"> </div> <div class="card-body"> <h4 class="card-title">Post Title</h4> <p class="card-text"> proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <div class="card-footer"> <a href="" class="card-link">Read more</a> </div> </div> </div> </div> </div> </div> We need to add some CSS style to the cards: .blog{ margin: 4em 0; position: relative; } .blog h1{ color:#F97300; margin: 2em; } .blog .card{ box-shadow: 0 0 20px #ccc; } .blog .card img{
  • 21. width: 100%; height: 12em; } .blog .card-title{ color:#F97300; } .blog .card-body{ padding: 1em; } After adding the Blog section to our website, the design should now look something like this:
  • 23. Cool isn’t it?   Team Section In this section we will use the grid system to distribute even space between images. Each image takes up 3 columns (.col-md-3) of the container — that equals 25% of the total space. Our HTML structure: <!-- Team section --> <div class="team"> <div class="container"> <h1 class="text-center">Our Team</h1> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img src="images/team-2.jpg" class="img-fluid" alt="team"> <div class="des"> Sara </div> <span class="text-muted">Manager</span>
  • 24. </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img src="images/team-3.jpg" class="img-fluid" alt="team"> <div class="des"> Chris </div> <span class="text-muted">S.enginner</span> </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img src="images/team-2.jpg" class="img-fluid" alt="team"> <div class="des"> Layla </div> <span class="text-muted">Front End Developer</span> </div> <div class="col-lg-3 col-md-3 col-sm-12 item"> <img src="images/team-3.jpg" class="img-fluid" alt="team"> <div class="des"> J.Jirard </div> <span class="text-muted">Team Manger</span> </div> </div> </div> </div> And let’s add some style: .team{ margin: 4em 0; position: relative; } .team h1{ color:#F97300; margin: 2em; } .team .item{ position: relative; } .team .des{ background: #F97300; color: #fff; text-align: center;
  • 25. border-bottom-left-radius: 93%; transition:.3s ease-in-out; } Adding an overlay to the image on-hover using animation would be nice  . To make this effect , add the styles below to main.css file: .team .item:hover .des{ height: 100%; background:#f973007d; position: absolute; width: 89%; padding: 5em; top: 0; border-bottom-left-radius: 0; } Super cool!   Contact Form
  • 26. The Contact Form is the last section to add, then we are done  . The Contact Form section will contain a form through which visitors can send an email or give feedback. We will use some Bootstrap classes to make the design beautiful and responsive. Like Bootstrap 3, Bootstrap 4 also uses the .form-control class for input fields, but there are some new features added — like switching from .input-group-addon (deprecated) to .input-group- prepend (to use icons as labels ). See Bootstrap 4 document for more information. In our Contact form we will wrap each input between a div that has the class .form-group. The index.html file now looks something like this: <!-- Contact form --> <div class="contact-form"> <div class="container"> <form> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <h1>Get in Touch</h1>
  • 27. </div> <div class="col-lg-8 col-md-8 col-sm-12 right"> <div class="form-group"> <input type="text" class="form-control form-control-lg" placeholder="Your Name" name=""> </div> <div class="form-group"> <input type="email" class="form-control form-control- lg" placeholder="YourEmail@email.com" name="email"> </div> <div class="form-group"> <textarea class="form-control form-control-lg"> </textarea> </div> <input type="submit" class="btn btn-secondary btn-block" value="Send" name=""> </div> </div> </form> </div> </div> Contact section’styles : main.css .contact-form{ margin: 6em 0; position: relative; } .contact-form h1{ padding:2em 1px; color: #F97300; } .contact-form .right{ max-width: 600px; } .contact-form .right .btn-secondary{ background: #F97300; color: #fff; border:0; }
  • 28. .contact-form .right .form-control::placeholder{ color: #888; font-size: 16px; } Fonts I think default fonts are ugly so we are going to use the Google Font API, and we’ll choose Raleway which is a nice font and appropriate to our template. Add this link into your main.css file: @import url('https://fonts.googleapis.com/css?family=Raleway'); and set the global style to HTML and heading tags: html,h1,h2,h3,h4,h5,h6,a{ font-family: "Raleway"; } Scroll Effect
  • 29. The last thing missing is scroll effect. Here, we’ll have to use some JQuery. Don’t worry  if you are not familiar with it, just add this code into yourmain.js file: $(".navbar a").click(function(){ $("body,html").animate({ scrollTop:$("#" + $(this).data('value')).offset().top },1000) }) and add a data-value attribute to each navbar link: <li class="nav-item"> <a class="nav-link" data-value="about" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link " data-value="portfolio" href="#">Portfolio</a> </li> <li class="nav-item"> <a class="nav-link " data-value="blog" href="#">Blog</a> </li> <li class="nav-item"> <a class="nav-link " data-value="team" href="#"> Team</a> </li> <li class="nav-item"> <a class="nav-link " data-value="contact" href="#">Contact</a> </li> Set an id attribute to each section. Note: The id must be identical to the data-value attribute in the navbar link for the scroll to work: <div class="about" id="about"></div>
  • 30. Wrap-up and Conclusion Bootstrap 4 is a great option for building your web application. It delivers high quality of UI elements and it’s easy to customize, integrate and use. It will also help you to include responsiveness in your website, therefore delivering a premium user experience to your users. You will find the project’s files on GitHub. Prepared By : ViASTUDY Source: medium.freecodecamp.org