Table of Contents for
Bootstrap 4 – Responsive Web Design

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Bootstrap 4 – Responsive Web Design by Jason Marah Published by Packt Publishing, 2017
  1. Cover
  2. Table of Contents
  3. Bootstrap 4 – Responsive Web Design
  4. Bootstrap 4 – Responsive Web Design
  5. Credits
  6. Preface
  7. What you need for this learning path
  8. Who this learning path is for
  9. Reader feedback
  10. Customer support
  11. 1. Module 1
  12. 1. Getting Started
  13. Setting up the framework
  14. Building our first Bootstrap example
  15. Optionally using the CDN setup
  16. Community activity
  17. Bootstrap and web applications
  18. Browser compatibility
  19. Summary
  20. 2. Creating a Solid Scaffolding
  21. Building our scaffolding
  22. Fluid container
  23. We need some style!
  24. Manipulating tables
  25. Like a boss!
  26. Final thoughts
  27. Summary
  28. 3. Yes, You Should Go Mobile First
  29. Bootstrap and the mobile-first design
  30. How to debug different viewports at the browser
  31. Cleaning up the mess
  32. Creating the landing page for different devices
  33. Summary
  34. 4. Applying the Bootstrap Style
  35. Summary
  36. 5. Making It Fancy
  37. Paying attention to your navigation
  38. Dropping it down
  39. Making an input grouping
  40. Getting ready for flexbox!
  41. Summary
  42. 6. Can You Build a Web App?
  43. Adding the navigation
  44. Do a grid again
  45. Playing the cards
  46. Implementing the main content
  47. Creating breadcrumbs
  48. Finishing with the right-hand-side content
  49. Summary
  50. 7. Of Course, You Can Build a Web App!
  51. Waiting for the progress bar
  52. Creating a settings page
  53. Summary
  54. 8. Working with JavaScript
  55. Awesome Bootstrap modals
  56. Creating our custom modal
  57. A tool for your tip
  58. Pop it all over
  59. Making the menu affix
  60. Finishing the web app
  61. Summary
  62. 9. Entering in the Advanced Mode
  63. The last navigation bar with flexbox
  64. Filling the main fluid content
  65. Filling the main content
  66. Overhead loading
  67. Fixing the toggle button for mobile
  68. Summary
  69. 10. Bringing Components to Life
  70. Fixing the mobile viewport
  71. Learning more advanced plugins
  72. Summary
  73. 11. Making It Your Taste
  74. Working with plugin customization
  75. The additional Bootstrap plugins
  76. Creating our Bootstrap plugin
  77. Defining the plugin methods
  78. Creating additional plugin methods
  79. Summary
  80. 2. Module 2
  81. 1. Introducing Bootstrap 4
  82. Summary
  83. 2. Using Bootstrap Build Tools
  84. Download the Bootstrap source files
  85. Setting up the blog project
  86. Setting up the JSON files
  87. Creating our first page template
  88. Summary
  89. 3. Jumping into Flexbox
  90. Ordering your Flexbox
  91. Wrapping your Flexbox
  92. Setting up the Bootstrap Flexbox layout grid
  93. Setting up a Flexbox project
  94. Designing a single blog post
  95. Summary
  96. 4. Working with Layouts
  97. Inserting rows into your layout
  98. Adding columns to your layout
  99. Choosing a column class
  100. Creating a simple three-column layout
  101. Mixing column classes for different devices
  102. Coding the blog home page
  103. Using responsive utility classes
  104. Summary
  105. 5. Working with Content
  106. Learning to use typography
  107. Customizing headings
  108. How to style images
  109. Coding tables
  110. Summary
  111. 6. Playing with Components
  112. Basic button examples
  113. Creating outlined buttons
  114. Checkbox and radio buttons
  115. Coding forms in Bootstrap 4
  116. Creating an inline form
  117. Adding validation to inputs
  118. Using the Jumbotron component
  119. Adding the Label component
  120. Using the Alerts component
  121. Using Cards for layout
  122. Updating the Blog index page
  123. How to use the Navs component
  124. Adding Breadcrumbs to a page
  125. Using the Pagination component
  126. How to use the List Group component
  127. Summary
  128. 7. Extending Bootstrap with JavaScript Plugins
  129. Coding Tooltips
  130. Avoiding collisions with our components
  131. Using Popover components
  132. Using the Collapse component
  133. Coding an Accordion with the Collapse component
  134. Coding a Bootstrap Carousel
  135. Summary
  136. 8. Throwing in Some Sass
  137. Using Sass in the blog project
  138. Importing partials in Sass
  139. Creating a collection of variables
  140. Customizing components
  141. Writing a theme
  142. Summary
  143. 9. Migrating from Version 3
  144. Big changes in version 4
  145. Updating your variables
  146. Additional global changes
  147. Other font updates
  148. Migrating components
  149. Migrating JavaScript
  150. Miscellaneous migration changes
  151. Summary
  152. 3. Module 3
  153. 1. Revving Up Bootstrap
  154. What Bootstrap 4 Alpha 4 has to offer
  155. Setting up our project
  156. Summary
  157. 2. Making a Style Statement
  158. Image elements
  159. Responsive utilities
  160. Helper classes
  161. Text alignment and transformation
  162. Summary
  163. 3. Building the Layout
  164. Adding Bootstrap components
  165. Summary
  166. 4. On Navigation, Footers, Alerts, and Content
  167. Improving navigation using Scrollspy
  168. Customizing scroll speed
  169. Icons
  170. Using and customizing alerts
  171. Creating a footer
  172. Creating and customizing forms
  173. Form validation
  174. Progress indicators
  175. Adding content using media objects
  176. Figures
  177. Quotes
  178. Abbreviations
  179. Summary
  180. 5. Speeding Up Development Using jQuery Plugins
  181. Enhanced pagination using bootpag
  182. Displaying images using Bootstrap Lightbox
  183. Improving our price list with DataTables
  184. Summary
  185. 6. Customizing Your Plugins
  186. Customizing plugins
  187. Writing a custom Bootstrap jQuery plugin
  188. Summary
  189. 7. Integrating Bootstrap with Third-Party Plugins
  190. Hover
  191. Summary
  192. 8. Optimizing Your Website
  193. Minifying CSS and JavaScript
  194. Introducing Grunt
  195. Running tasks automatically
  196. Stripping our website of unused CSS
  197. JavaScript file concatenation
  198. Summary
  199. 9. Integrating with AngularJS and React
  200. Introducing React
  201. Summary
  202. Bibliography
  203. Index

Updating the Blog index page

Now that we've covered the card component, it's time to set up the main layout for our Blog index page. The design is going to rely heavily on the Card component, so let's get to it. First of all, open up index.ejs in your text editor and find the body of the page section. The left column will look like this:

<div class="col-md-8"> 

Within this <div> currently is some filler text. Delete the filler text and insert the following Card component, which will be our first Blog post:

<div class="card"> 
  <img class="card-img-top img-fluid" src="img/image.jpg" alt="Card image cap"> 
  <div class="card-block"> 
    <h4 class="card-title">Post title</h4> 
    <p><small>Posted by <a href="#">Admin</a> on January 1, 2016 in <a href="#">Category</a></small></p> 
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 
    <a href="#" class="btn btn-primary">Read More</a> 
  </div> 
</div> 

Now that we've added our first card to the Blog roll, let's break down what's happening:

  • I've started by including a photo I took in Nova Scotia a few summers ago. I've given it a class of .img-fluid so it stretches the width of the card.
  • From there, I've set up my card exactly like I taught you previously, but in this case, I've added some real content for a blog.

Let's go ahead and add the rest of the Card component code for the blog roll. Insert the following code after the first Card in the left column:

<div class="card"> 
  <div class="card-block"> 
    <h4 class="card-title">Post title</h4> 
    <p><small>Posted by <a href="#">Admin</a> on January 1, 2016 in <a href="#">Category</a></small></p> 
    <p>Pellentesque habitant morbi tristique...</p> 
    <a href="#" class="btn btn-primary">Read More</a> 
  </div> 
</div> 
<div class="card"> 
  <img class="card-img-top img-fluid" src="img/image.jpg" alt="Card image cap"> 
  <div class="card-block"> 
    <h4 class="card-title">Post title <span class="label label-success">Updated</span></h4> 
    <p><small>Posted by <a href="#">Admin</a> on January 1, 2016 in <a href="#">Category</a></small></p> 
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 
    <a href="#" class="btn btn-primary">Read More</a> 
  </div> 
</div> 
<div class="card"> 
  <div class="card-block"> 
    <h4 class="card-title">Post title</h4> 
    <p><small>Posted by <a href="#">Admin</a> on January 1, 2016 in <a href="#">Category</a></small></p> 
    <p>Pellentesque habitant morbi tristique senectus...</p> 
    <a href="#" class="btn btn-primary">Read More</a> 
  </div> 
</div> 

That's a long chunk of code. The filler text is just in there to give you an idea. Feel free to remove that or replace it with actual text. Now that we've filled out the left column with a good amount of content, your page should look like this:

Updating the Blog index page

Now that the main blog roll content is complete, let's also add the right column content.

Adding the sidebar

Let's add some more content to the index page by adding the sidebar. We'll also use the Card component here, but in this case, some different variations of it. Go back to index.ejs and remove the filler text from the second column. Instead, insert the following Card code:

<div class="card card-block"> 
  <h5 class="card-title">Recent Posts</h5> 
  <div class="list-group"> 
    <button type="button" class="list-group-item">Cras justo odio</button> 
    <button type="button" class="list-group-item">Dapibus ac facilisis in</button> 
    <button type="button" class="list-group-item">Morbi leo risus</button> 
    <button type="button" class="list-group-item">Porta ac consectetur ac</button> 
    <button type="button" class="list-group-item">Vestibulum at eros</button> 
  </div> 
  <div class="m-t-1"><a href="#">View More</a></div> 
</div> 

You'll notice in this Card I'm using a different variation, which is the List Group option. To do this, follow these steps:

  • Create a new <div> with a class of .list-group inside your card.
  • Inside, insert a <button> with a class of .list-group-item on it for every item of your list. I've added five different options.

Once you're done, save your file and it should look like this in the browser:

Adding the sidebar

As you can see, that will draw a nice-looking sidebar list component. Let's fill out the rest of the sidebar by inserting the following code after the first Card component:

<div class="card card-block"> 
  <h5 class="card-title">Archives</h5> 
  <div class="list-group"> 
    <button type="button" class="list-group-item">Cras justo odio</button> 
    <button type="button" class="list-group-item">Dapibus ac facilisis in</button> 
    <button type="button" class="list-group-item">Morbi leo risus</button> 
    <button type="button" class="list-group-item">Porta ac consectetur ac</button> 
    <button type="button" class="list-group-item">Vestibulum at eros</button> 
  </div> 
  <div class="m-t-1"><a href="#">View More</a></div> 
</div> 
<div class="card card-block"> 
  <h5 class="card-title">Categories</h5> 
  <div class="list-group"> 
    <button type="button" class="list-group-item">Cras justo odio</button> 
    <button type="button" class="list-group-item">Dapibus ac facilisis in</button> 
    <button type="button" class="list-group-item">Morbi leo risus</button> 
    <button type="button" class="list-group-item">Porta ac consectetur ac</button> 
    <button type="button" class="list-group-item">Vestibulum at eros</button> 
  </div> 
  <div class="m-t-1"><a href="#">View More</a></div> 
</div> 

This will produce two more List Group Card components for the sidebar of your blog project. Once it's all done, the entire page should now look like this:

Adding the sidebar

That concludes the user of the Card component on the index page. The last page we need to set up with the Card component is our Blog post page.

Setting up the Blog post page

The index page is a list of all the Blog posts in our project. The last page we need to setup is the Blog post page, which is just a single post in our project. Open up the blog-post.ejs template you created earlier in the book and let's start updating some code. Head down to the page body section and find this line of code:

<div class="col-md-8"> 

Currently, you'll see some filler text in that <div>; let's replace it with the following code:

<div class="card"> 
  <div class="card-block"> 
    <p><small>Posted by <a href="#">Admin</a> on January 1, 2016 in <a href="#">Category</a></small></p> 
    <p>Pellentesque habitant morbi tristique senectus et...</p> 
    <p><code>&lt;p&gt;this is what a code sample looks like&lt;/p&gt;</code></p> 
    <p>Pellentesque habitant morbi tristique senectus et netus...</p> 
    <!-- pre sample start //--> 
    <h4>pre sample code</h4> 
    <pre>This is what code will look like</pre> 
    <!-- pre sample end //--> 
    <!-- image //--> 
    <h4>responive image</h4> 
    <p><img src="img/image.jpg" class="img-fluid" alt="Responsive image"></p> 
    <!-- table //--> 
    <h4>table</h4> 
    <table class="table"> 
      <thead> 
        <tr> 
          <th>#</th> 
          <th>First Name</th> 
          <th>Last Name</th> 
          <th>Username</th> 
        </tr> 
      </thead> 
      <tbody> 
        <tr> 
          <th scope="row">1</th> 
          <td>john</td> 
          <td>smith</td> 
          <td>@jsmith</td> 
        </tr> 
        <tr> 
          <th scope="row">2</th> 
          <td>steve</td> 
          <td>stevens</td> 
          <td>@steve</td> 
        </tr> 
        <tr> 
          <th scope="row">3</th> 
          <td>mike</td> 
          <td>michaels</td> 
          <td>@mike</td> 
        </tr> 
      </tbody> 
    </table> 
  </div> 
</div> 

There's a good chunk of things going on in this code. I've thrown in a few other components we've already learned about so you can see them in action. The Card component has the following things included inside it:

  • Text, <code> and <pre> tags
  • Tables
  • Images

Let's also update this template to use the same sidebar code as the index page. Copy the right column code from the index template and paste it into the same location in the blog post template.

When you are done, the page should now look like this:

Setting up the Blog post page

As you can see, we're using a single Card component to hold all of the content for the body of the page. We're also using the same Card components for the sidebar that we copied over from the index page. Now that we've added the Cards to all of our page templates, let's get back to learning about some other Content components in Bootstrap 4.