Reader small image

You're reading from  Bootstrap 4 Cookbook

Product typeBook
Published inJun 2017
Reading LevelBeginner
PublisherPackt
ISBN-139781785889295
Edition1st Edition
Languages
Right arrow
Author (1)
Ajdin Imsirovic
Ajdin Imsirovic
author image
Ajdin Imsirovic

Ajdin Imsirovic is a full-stack web developer who has published several courses on the subject of web design and web development. He has also authored three books, Bootstrap 4 Cookbook, Elm Web Development, and Vue.js Quick Start Guide. In his fourth book, Vue CLI 3 Quick Start Guide, he introduces readers to the rich ecosystem of frontend tooling and best practices.
Read more about Ajdin Imsirovic

Right arrow

Adding Font Awesome to Bootstrap navbar


In this recipe, we will build a navbar with a dropdown that will hold recipes for the chapter, and two additional links to showcase different navigation scenarios. To see the final result, open the chapter5/complete code's app folder, and run the git bash on it. Follow it up with the harp server command, and navigate to localhost:9000 in your browser to see the result we will achieve in this recipe.

Upon opening the web page as explained in the preceding paragraph, there will be four top-level links, and each of them will have an icon next to it. The second link is a dropdown, whereas the others are regular links.

Getting ready

In this recipe, we are using a customized version of the navbar used on the official Bootstrap 4 site at https://v4-alpha.getbootstrap.com/. Feel free to inspect the home page in developer tools and get yourself acquainted with the structure of the navbar on the site.

How to do it…

  1. Open the currently empty file located at chapter5...

Placing a single Bootstrap navbar dropdown to the right


In this recipe, we are also using a customized version of the navbar used on the official Bootstrap 4 website. The navbar is somewhat similar to the one used in the preceding recipe.

Getting ready

In this recipe, we will deal with the drop-down issue for the drop-down bubble (secondary links) in the navbar. Refer to the official documentation regarding dropdowns at https://v4-alpha.getbootstrap.com/components/dropdowns/#menu-alignment.

How to do it…

  1. Open chapter5/start/main.scss and comment out all the @import statements except the one that pertains to this recipe:
@import "./bower_components/bootstrap/scss/bootstrap.scss";
@import "./bower_components/bootstrap/scss/_mixins.scss";
@import "./bower_components/font-awesome/scss/font-awesome.scss";
@import "./bower_components/hover/scss/hover.scss";

// @import "recipe05-01.scss";
   @import "recipe05-02.scss";
// @import "recipe05-03.scss"; 
// @import "recipe05-04.scss"; 
// @import "recipe05...

Making a transparent navbar on a darker background


In this recipe, we continue using a customized version of the navbar used on the official Bootstrap 4 website. This recipe will result in a completely different look based on the HTML structure that is almost the same as in the previous recipes in this chapter. To achieve this, we will be relying heavily on SCSS.

Getting ready

To get ready for this recipe, search for the scss folder inside the bower_components/bootstrap folder. We will take some bits and pieces from the code in this folder and override its behavior to get the desired effect.

How to do it…

  1. Open chapter5/start/main.scss and comment out all the @import statements except the one that pertains to this recipe:
@import "./bower_components/bootstrap/scss/bootstrap.scss";
@import "./bower_components/bootstrap/scss/_mixins.scss";
@import "./bower_components/font-awesome/scss/font-awesome.scss";
@import "./bower_components/hover/scss/hover.scss";

// @import "recipe05-01.scss";
// @import...

Creating a Navbar with Icons and Flexbox


In this recipe, we will create a wonderful navbar. It will have large icons as links. The text to describe the icons will be placed below each icon. The icons used will be Font Awesome.

Getting ready

To get ready for this recipe, preview the completed navbar in chapter5/complete/recipe05 folder. Run the hard server and preview the navbar in your browser. Resize the browser window to see the behavior of the navbar. On smaller resolutions, click the toggle menu button to see the positioning of navbar links.

How to do it…

  1. Open chapter5/start/main.scss and comment out all the @import statements except the one that pertains to this recipe:
@import "./bower_components/bootstrap/scss/bootstrap.scss";
@import "./bower_components/bootstrap/scss/_mixins.scss";
@import "./bower_components/font-awesome/scss/font-awesome.scss";
@import "./bower_components/hover/scss/hover.scss";

// @import "recipe05-01.scss";
// @import "recipe05-02.scss";
// @import "recipe05...

Adding Yamm3 Megamenu images to a navbar dropdown


In this recipe, we will add a megamenu list of images to a Bootstrap 4 navbar dropdown, using the Yamm3 library. The library is intended for Bootstrap 3, so we will have to make some adjustments to the code. In other words, we will not be able to plug and play this library. Instead, we will have to customize the HTML structure of the provided example in order to make it work in Bootstrap 4.

Getting ready

To get ready for this recipe, take a look at the drop-down component documentation available at https://v4-alpha.getbootstrap.com/components/dropdowns/. Also, refer to the navbar component documentation at https://v4-alpha.getbootstrap.com/components/navbar/. Finally, visit the address for Yamm3 (yet another megamenu for Bootstrap 3), at https://github.com/geedmo/yamm3.

Note

Alternatively, you could install Yamm3 via bower, using the following command in your console:

bower install yamm3 --save

How to do it…

  1. Open chapter5/start/main.scss and...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Bootstrap 4 Cookbook
Published in: Jun 2017Publisher: PacktISBN-13: 9781785889295
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Ajdin Imsirovic

Ajdin Imsirovic is a full-stack web developer who has published several courses on the subject of web design and web development. He has also authored three books, Bootstrap 4 Cookbook, Elm Web Development, and Vue.js Quick Start Guide. In his fourth book, Vue CLI 3 Quick Start Guide, he introduces readers to the rich ecosystem of frontend tooling and best practices.
Read more about Ajdin Imsirovic