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

Coding tables

Tables in Bootstrap 4 are largely unchanged from the previous version of the framework. However, there are a few new things, like inverse color table options and responsive tables. Let's start with the basics and we will build in the new features as we go.

Setting up the basic table

The basic table structure in Bootstrap takes advantage of almost all the available HTML table tags. The header is wrapped in <thead> and the body <tbody> tags. This will allow additional styling as we get into the inverse table layout. For now, let's see how we put together a basic table in Bootstrap:

<table class="table"> 
<thead> 
  <tr> 
    <th>first name</th> 
    <th>last name</th> 
    <th>twitter</th> 
  </tr> 
</thead> 
<tbody> 
  <tr> 
    <td>john</td> 
    <td>smtih</td> 
    <td>@jsmtih</td> 
  </tr> 
  <tr> 
    <td>steve</td> 
    <td>stevens</td> 
    <td>@stevens</td> 
  </tr> 
  <tr> 
    <td>mike</td> 
    <td>michaels</td> 
    <td>@mandm</td> 
  </tr> 
</tbody> 
</table> 

As you can see, the syntax is fairly straightforward. The only class being applied is the root table class on the <table> tag. This needs to be applied to any table variation you are using in Bootstrap. This will produce a table that looks like the following in the browser:

Setting up the basic table

As you can see, the syntax is fairly straightforward. The only class being applied is the root table class on the <table> tag. This needs to be applied to any table variation you are using in Bootstrap.

Inversing a table

Let me quickly show you one of the new table classes in Bootstrap 4. If we add the class table-inverse to the <table> tag, the table colors will flip to be a dark background with light text. Here's the code you need to change:

<table class="table table-inverse"> 
  ... 
</table> 

This slight variation in code will produce a table that looks like this:

Inversing a table

That's a pretty handy trick to know if you need to get a quick variation of the basic table styles going.

Inversing the table header

Perhaps you don't want to inverse the entire table? If that is the case, you can use the thead-inverse class on the <thead> tag to only inverse that row:

<table class="table"> 
<thead class="thead-inverse"> 
  ... 
</thead> 
  ... 
</table> 

If this variation is applied, then your table will look like this:

Inversing the table header

If you're looking for a more subtle design for your project, this approach may be more appealing to you.

Adding striped rows

Although not new to Bootstrap 4, the table-striped class is one that I use all the time. Applying this class to the <table> tag will add zebra striping to your table, starting with the first row in the body and applying a light grey background color on all the odd numbered rows:

<table class="table table-striped"> 

Using this class will produce a table that looks like this:

Adding striped rows

Now our table is starting to come together. With a few classes, we can get an attractive-looking layout. Let's see what else we can do with tables.

Adding borders to a table

Another style that is regularly used is to add borders to your table. This can be done in the same way as stripes. Just change or add another class to the <table> tab called table-bordered. For this example, I'll remove the stripes and add the borders:

<table class="table table-bordered"> 

Now that we've added the borders and taken away the stripes, our table should look like this:

<table class="table table-bordered table-striped"> 

Adding borders to a table

It's important to know that you can combine the table classes and use more than one. What if you wanted a table with stripes and borders? You can do that easily, by including both of the corresponding classes.

Adding a hover state to rows

It's possible and easy to add a hover state to each of your table rows. To do so, you just need to add the table-hover class to the <table> tag. When used, if you hover over a row in the table, its background color will change to indicate a state change:

<table class="table table-hover"> 

Here I've removed the other table classes to show you the basic hover table option. When viewed in the browser, the table should look like the following when a row is hovered over with the mouse:

Adding a hover state to rows

In some cases you may require a table with smaller text and compressed height. This can be done by adding the table-sm class to the <table> tag. This will make the look of the table more compact when viewing it:

<table class="table table-sm"> 

If you choose to use this class, your table should look like this:

Adding a hover state to rows

Creating smaller tables

That concludes the core table variations that you can apply through a simple CSS class. Before we move on, there are a couple more important points on tables that we should go over.

Color-coating table rows

In some cases, you may want to color the background of a table row in a different color. This can easily be achieved through the use of some included contextual classes. There are five different color variations you can choose from:

  • table-active is the hover color, light grey by default
  • table-success is green for a positive action
  • table-info is blue for an informational highlight
  • table-warning is yellow to call out something that needs attention
  • table-danger is red for a negative or error action

The preceding classes can be applied to either a <tr> or <td> tag. If I apply all of these color variations to a single table, they look like this:

Color-coating table rows

As you can see, these classes can be useful for validation or just highlighting a particular row that needs to stand out more.

Making tables responsive

Adding responsiveness to tables has never been very easy to do with CSS. Thankfully, Bootstrap 4 comes with some support built right in that you can easily take advantage of. To make a table responsive, you simply need to wrap a <div> around your <table> that has a class of table-responsive on it:

<div class="table-responsive"> 
  <table class="table"> 
    ... 
  </table> 
</div> 

If you view the table on a viewport that is smaller than 768px, then the table cells will scroll horizontally, so they can all be viewed. If the viewport is larger, you will see no difference in the table compared to a regular one.