Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Bootstrap 4 Cookbook

You're reading from   Bootstrap 4 Cookbook Solutions to common problems faced in Responsive Web Design

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781785889295
Length 338 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Ajdin Imsirovic Ajdin Imsirovic
Author Profile Icon Ajdin Imsirovic
Ajdin Imsirovic
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Installing Bootstrap 4 and Comparing Its Versions FREE CHAPTER 2. Layout Like a Boss with the Grid System 3. Power Up with the Media Object, Text, Images, and Tables 4. Diving Deep into Bootstrap 4 Components 5. Menus and Navigations 6. Extending Bootstrap 4 7. Make Your Own jQuery Plugins in Bootstrap 4 8. Bootstrap 4 Flexbox and Layouts 9. Workflow Boosters 10. Creating a Blog with Jekyll and Bootstrap 4 11. Bootstrap 4 with ASP.NET Core 12. Integrating Bootstrap 4 with React and Angular

Customizing the styles of Bootstrap 4 docs

In the previous recipe, we built our own copy of Bootstrap 4 docs, running on Jekyll. In this recipe, we will see how to change the styling of our Bootstrap 4 docs by making simple changes to Sass variables.

Getting ready

For this recipe to work, you need to complete the previous two recipes, Installing Bootstrap 4 to c9 IDE using npm and Installing Bootstrap 4 to c9 IDE via git. The following steps will show you how to tweak the look of the docs by changing some of the Sass variables in the scss folder.

How to do it...

  1. Stop the running Jekyll server by clicking inside the Bash console tab and using Ctrl + C.
  2. Navigate to the scss folder and open the _variables.scss file:
      cd && cd workspace/scss && c9 _variables.scss
In Windows, the path is ../bootstrap/scss/.
  1. Find the Sass variable $enable-rounded, and uncomment the line it is on, so that it looks like this:
      // $enable-rounded: true !default;
  1. On the very next line, paste in the following code:
      $enable-rounded: false !default;
In Sass, using !default is like adding an unless this is already assigned qualifier to a variable. Thus, if you are overriding variables in some other file, make sure that there is no !default after the changed value of false and save the file.
  1. Still in console, change directory into the scss folder by running cd scss command. Then, run the following command:
      sass bootstrap.scss ../dist/css/bootstrap.css

This command will recompile SCSS into CSS for Bootstrap docs.

In Windows, make sure that you run the preceding command from the ../bootstrap/ folder, that is the root, as cloned earlier using git. On c9.io, you can utilize multiple Bash console tabs, so there is no need to renavigate to root.
  1. Go back out from the scss folder, by running cd ... Back in the console tab, run the following command:
      bundle exec jekyll serve --watch --host $IP --port $PORT --  
baseurl ''

When you refresh the webpage, it will now show the homepage with the Download Bootstrap button with sharp edges, instead of rounded ones, as seen in the following screenshot:

  1. Back in the _variables.scss file, override the default values by adding more changes:
      $white: #ddd;
$enable-rounded: false;
$spacer: 8rem;
$font-size-base: 2rem;

You should probably make use of your code editor's search and replace function to complete this step. Once you have completed the step, make sure that you save the file.

  1. Recompile SCSS again by pointing your console to the scss folder with cd scss, then running the command from step 6 once again:
      sass bootstrap.scss ../dist/css/bootstrap.css
  1. Rebuild Jekyll by running:
      bundle exec jekyll build; 
  1. Go into _gh_pages and run Jekyll server:
      jekyll serve --watch --host $IP --port $PORT --baseurl '' 

This should result in the following changes on the docs website:

You have been reading a chapter from
Bootstrap 4 Cookbook
Published in: Jun 2017
Publisher: Packt
ISBN-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.
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 $19.99/month. Cancel anytime