Contents  >

Practical Bootstrap Layouts

Learning Goals

At the end of this Tutorial you will be able to:

You can view a finished version of the Bootstrap grid layout web page you will create in this Tutorial by clicking the link below. The finished web page will open in a new tab of your web browser.

Sample image bootstrap-practical-layouts.html

Contents

About ‘whitespace’ in web page layout

Creating your Bootstrap layout web page

Downloading sample images

Adding visual guides to your web page

Downloading the custom stylesheet

Linking to the custom CSS file

Adding background colours to grid columns

Adding background colours to grid rows

Adding images to grid rows and columns

Removing the red-coloured border guides

Uploading your Bootstrap folder to GitHub

Further resources

About ‘whitespace’ in web page layout

The term white space comes from the world of print design where content - text and images - are (mostly) printed on white-coloured paper. White space means space in a design layout that is empty. Although it contains nothing, white space is just as important as any of the content it surrounds for this reason: it makes text more inviting to read.

Here are some examples of white space in use in print design.

Introduction to HTML

As in print, so too in web design.

Introduction to HTML

Because electronic screens - and modern printing processes - can create almost any background colour, the original term of white space is increasingly known by the alternative term of negative space.

In this Tutorial you will use a new stylesheet named bootstrap-custom.css that adjusts the Bootstrap grid so that it is more suited to creating web page layouts with whitespacing.

Creating your Bootstrap layout web page

Let’s create a Bootstrap-based web page for working with multi-column layout grids. Here are the steps:

  1. In VS Code, open the bootstrap-grid.html web page from your bootstrap sub-folder. You created this file and its folder structure in the previous Tutorial.
  2. Use the File | Save As command to save the file with the following new name:   bootstrap-practical-layouts.html
  3. Update the web page title and description as shown below. Introduction to HTML

This new web page is located within your folder structure as shown below.

Introduction to HTML

Downloading sample images

You will need some sample images to work with. Right-click on the images below, choose Save Image As from the context menu, and download them to your C:/websites/bootstrap/assets/img sub-folder.

 

Your folder structure should now look as shown below.

Introduction to HTML

Adding visual guides to your web page

When creating web pages, designers often add coloured borders to div tags to guide their actions. Let's do this with the new web page you have created.

For simplicity, we will add this new coloured border CSS class directly to the web page instead of to a separate stylesheet file.

  1. In VS Code, add the following to the head section of your bootstrap-practical-layouts.html file, just before the closing </head> tag.
    <style>
       .container { border: solid 2px red }
    </style>
    Your head section should now look as shown below.
  2. Save your bootstrap-practical-layouts.html file.

View your bootstrap-practical-layouts.html web page in your browser. As you can see, all the container div blocks are now highlighted with a two pixel-wide red border.

Project: Smooth Smoothies

Downloading the custom stylesheet

Next, we will download a custom stylesheet that adjusts the default Bootstrap grid so that it becomes a more practical starting point for designing modern-looking web pages.

  1. In your web browser, display the following stylesheet.   bootstrap-custom.css
  2. Right-click on the file, choose Save Page As from the context menu, and save the stylesheet in your bootstrap/assets/css sub-folder.   Ensure the Save as type: dropdown list is set to the correct file type. Working with Internal Hyperlinks

Your folder structure should now look as shown below.

Introduction to HTML

Adding background colours to grid columns

In addition to styles that increase the spacing around the Bootstrap grid elements, the bootstrap/assets/css stylesheet also includes some sample background colours to work with.

Introduction to HTML

Let's experiment with some of these by adding them to your bootstrap-practical-layouts.html web page.

  1. In VS Code, add the bg-beige-light CSS class to the first of the two, 50% wide-columns near the top of your web page.   To the second of the two, 50% wide-columns, add the bg-salmon-light CSS class. Project: Smooth Smoothies When you save your page, these columns will display in your browser as shown below. Project: Smooth Smoothies
  2. To all three columns of the three-column layout, add the same bg-gray-light CSS class. Project: Smooth Smoothies When you save your page, these columns will display in your browser as shown below. Project: Smooth Smoothies
  3. Lastly, to each of the four columns near of the bottom of the web page, add one of these four CSS classes: bg-purple-dark, bg-crimson-dark, bg-blue-dark and bg-black-dark. Project: Smooth Smoothies When you save your page, these columns will display in your browser as shown below.
  4. Project: Smooth Smoothies

Notice that, when you added a dark background to a column, the text inside that column changed to white. This is the result of the following line in the bootstrap-custom.css stylesheet.

Project: Smooth Smoothies

This style rule states that: if the column contains a class whose name includes "-dark", set the colour of the font inside that column to white.

Adding background colours to grid rows

Next, let's add a background to an entire horizontal row, so that the background colour covers the full width of the browser screen.

  1. In your bootstrap-practical-layouts.html web page, wrap the entire first row inside a new div with a class of bg-green-light as shown below. Introduction to HTML
  2. Save your page. The first row at the top should now display in your browser as shown below. Project: Smooth Smoothies

You can see an example of the finished web page below.

Bootstrap page with background colours.

Adding images to grid rows and columns

In this next exercise you will add some sample images to your bootstrap-practical-layouts.html web page.

  1. In VS Code, to the first column at the top of the web page, copy-and-paste the link to the bambam-1200x300.jpg image
     <img src="assets/img/bambam-1200x300.jpg" alt="Bambam">
    Position the image to just above the h1 heading as shown below. Project: Smooth Smoothies When you save your page, you can see that the image is not displaying correctly. Project: Smooth Smoothies To ensure your images display correctly inside a Boostrap grid, you need always to add the img-fluid class to the image as shown below. Project: Smooth Smoothies Resave your web page and verify that the image now displays correctly in your web browser. Project: Smooth Smoothies
  2. In the second row of your web page, in each of the two columns, add the following image.
     <img src="assets/img/bambam-700x450.jpg" class="img-fluid" alt="Bambam"> 
    Position the image to just above the h2 sub-headings as shown below. Project: Smooth Smoothies
  3. In the third row of your web page, in each of the three columns, add the following image. <
     <img src="assets/img/bambam-700x400.jpg" class="img-fluid" alt="Bambam">
    Position the image to just above the h2 sub-headings as shown below. Project: Smooth Smoothies
  4. In the fourth row of your web page, in each of the three columns, add the same image again.
     <img src="assets/img/bambam-700x400.jpg" class="img-fluid" alt="Bambam">
    Position the image to just above the h2 sub-headings as shown below. Project: Smooth Smoothies

Save your web page and verify the images all display correctly in your web browser.

You can see an example of the finished web page below.

Bootstrap page with images.

Removing the red-coloured border guides

As a final step, remove the style from the head of the web page that adds the red-coloured borders to container elements.

github-signin

You can see an example of the finished web page below.

Bootstrap page without red borders.

Uploading your Bootstrap folder to GitHub

Follow these steps below to upload your entire Bootstrap folder to your website on GitHub.

  1. Open a new tab in your web browser and go to GitHub.com. If you are not already signed in to your GitHub account, sign in now. github-signin
  2. On your GitHub home page, click the name of the repository (‘repo’) that holds your web pages. Its name will look as follows, where username is your chosen username on GitHub.   username.github.io github-signin
  3. On the next GitHub screen displayed, click the Add file button near the right of the screen and choose Upload files from the dropdown list. github-upload-portfolio
  4. In File/Windows Explorer, select your bootstrap folder, and drag-and-drop it to your repository on GitHub. Introduction to Images
  5. Scroll down to the bottom of the GitHub screen, and accept or edit the short message (Add files via upload) in the Commit changes box.   Finally, click the green Commit changes button to upload your entire bootstrap folder and all the files it contains.

Your uploaded web page is published on GitHub at a web address similar to the following, where username is the username you have chosen for your GitHub account:

https://username.github.io/bootstrap/bootstrap-practical-layouts.html

It may take a few minutes for your uploaded files to appear on GitHub.

Further resources

Whitespace in Web Design: What It Is and Why You Should Use It
From Gisele Muller on Treehouse.

A Guide to Effective Use of White Space in Web Design
From Joanne Amos on Flywheel.

White Space Design: 20 Striking Examples and Best Practices
From Josesp Downes on Just in Mind.

What Is Whitespace? 9 Websites to Inspire Your Web Design
From Karla Cook on HubSpot Marketing Blog.

White-Space at Work: Why Less is More in Your Website Design
From Sherice Jacob on Crazyegg Blog.

White Space - A Perfect Option For Improving Usability In Web Designs
From Isabella Morris on Usability Geek.


Return to Contents.