Bootstrap 4 is currently the most popular front-end framework in the world. You can use it to build any kind of user interfaces, from admin templates to full-featured websites. In this step-by-step tutorial, we will have a look at how to build a responsive landing page with Bootstrap 4. You can even use it as a homepage or connect it to a specific marketing campaign.
Get to know more office.com/setup
The landing page we will build will have five sections:
a fixed navigation bar,
a hero section,
a three-column “Services” section,
a full-width “Contact” section, and
However, following the same logic, you can create other sections for testimonials, blog excerpts, and other content types, too. Here’s how the final landing page will look like:
- SET UP BOOTSTRAP 4
There are a couple of ways of getting started with Bootstrap 4. You can:
set up Bootstrap 4 using your own pipeline (choose this if you want to edit Sass files),
Bootstrap Landing Page by Developer Drive
<link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet">
<!-- Here comes the rest of the code --> <script src="scripts/jquery.min.js"></script> <script src="scripts/bootstrap.bundle.min.js"></script>
- CREATE THE NAVIGATION BAR
Bootstrap 4 comes with an awesome pre-designed navigation bar component that lets you add a responsive menu to your landing page with just a few lines of HTML. Insert the following code into the section of your HTML file:
The most important thing to know about Bootstrap 4 is that it has a utility class for almost everything. For instance, they have .bg-light (see above) that adds a light background and .bg-dark that adds a dark background to any HTML element. With Bootstrap 4, you can prototype your designs by barely touching any CSS code.
However, as the .fixed-top class fixes the navigation bar to the top, you need to make some extra space for it. So, add the following rule to your custom style.css file. Or, if you don’t want a fixed navigation bar, simply omit the .fixed-top class from your HTML code.
- COMPOSE THE HERO SECTION
Hero sections are an integral part of most landing pages. They usually include a full-width background image, a headline, a short description, and a call-to-action button. Fortunately, Bootstrap 4 has a pre-designed component called Jumbotron that allows you to easily add a hero section to your page. You need to add the .jumbotron class to the element that will hold the hero section:
The Best Solution for Your Business
We help you maximize performance and build a healthy organization.
If you want a full-width hero section, use the .container-fluid and .jumbotron-fluid classes. If you don’t want it to span the whole viewport, use .container and .jumbotron instead (see detailed explanation in the Jumbotron docs).
The code above also makes use of Bootstrap 4’s .display-3 and .lead typography classes and the .text-center text alignment class. Besides, it adds bottom padding to the lead text by using the .pb-4 class. If you want to use other margin and padding sizes check out how Bootstrap 4’s spacing classes work. For instance, the .pb-4 class adds the padding-bottom: 1.5rem !important; rule to any HTML element.
You also need to add a background image to the Jumbotron section in your custom style.css file. If you want you can override the background color of primary buttons, too:
background: url(“image.jpg”) no-repeat center;
Here’s how our example landing page looks like so far, with the navigation bar and the hero section:
Bootstrap 4 Landing Page Hero Section
- CREATE A THREE-COLUMN SECTION TO SHOWCASE SERVICES
To create a three-column Services section, use Bootstrap 4’s responsive grid system consisting of rows and columns that divide up the screen. By default, every row contains 12 columns (however, you can change this in your Sass settings). You can indicate the number of columns you want to use within the name of the column class. For example, .col-4 takes up 4 columns out of the 12.
Bootstrap 4 has five responsive breakpoints that define five grids: extra small (default), small, medium, large, and extra large. As the breakpoints are based on minimum width media queries, the column classes apply to their own grid and all the grids above.
For instance, in the code below, .col-md-4 applies to the medium, large, and extra large grids. This means that tablets and desktops will display the Services section in 3 equal columns next to each other. And, smartphones with extra small and small viewports will display them below each other (one column per row).
The code above also makes use of Bootstrap 4’s Card component that comes with five pre-built classes: .card, .card-img-top, .card-body, .card-title, and .card-text. The .h-100 class is one of Bootstrap 4’s sizing utility classes you can use on any element you want. It sets the height of each card to 100%.
You can also override the design of secondary buttons in your style.css file to match it with the rest of your landing page, for example:
- ADD A FULL-WIDTH CONTACT SECTION
You can add a full-width Contact section to your landing page using Bootstrap 4’s utility classes:
Get in touch with us today!
Send us a message and we will get back to you as soon as possible.Contact us
Similar to the Jumbotron section, you also need to add a background image to the Contact section in your style.css file: