Mon, Jun
3 New Articles

TechTip: A Primer to Bootstrap 4, Part 1

Development Tools / Utilities
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Let’s scratch the surface of the new version of Bootstrap.

You sit down in your office and fold your hands behind your neck. You are very pleased with yourself. You have just finished writing an RPG CGI program that will display sales data, Key Performance Indicators (KPIs) to show the production figures for last week, and the order intake split on country areas. Everything now runs fine on the intranet, and users can see it all when they connect their laptops to the VPN. Life is good, and you sing The Beatles’ “Don't Let Me Down” to yourself: Nobody ever loved me like she does. Oh, she does, yeah, she does.

Suddenly, you hear a knock on the door, and young Steven appears in the doorway: “Jan, when I look at your new websites on my mobile, they look a bit, umm, clumsy.” You suppress the urge to throw something at him and reply, “Well, Steven, who wants to see the data on a small mobile screen when you can see it on a widescreen laptop?” His reply cuts like a knife: “Everybody! What planet are you from?” He quickly walks away, leaving you with another Beatles song in your head: “Leave My Kitten Alone”: Well, Mr. Dog, I'm gonna hit you on the top of your head.

If this story sounds like something you have heard before (except for The Beatles’ songs), then Bootstrap might be something for you. Bootstrap lets you create responsive websites. I’ve already written a few articles (1, 2, 3) you should read so you get a basic understanding of the tool and how it fits into a mobile world.

One of many things that has changed in Bootstrap 4 is the use of Popper.js, which is used with modals, tools, tips, and likewise. Just include it and do not think more about it right now.

In the following examples, I use a Content Delivery Network (CDN) to copy the required data into my pages, but you can of course install locally if you prefer that.


Bootstrap is “mobile-first,” and you might as well start thinking that way every time you create something. Ask yourself, “How does my program look on a mobile screen?” If it will look good there, it will also work fine on larger screens.

The way Bootstrap handles responsiveness is by using breakpoints. In version 4, an .xl breakpoint has been added, so we now have the following to use:

  • .xs (the default) is for extra-small devices, screen width less than 576px.
  • .sm is for small devices, screen width equal to or greater than 576px.
  • .md is for medium devices, screen width equal to or greater than 768px.
  • .lg is for large devices, screen width equal to or greater than 992px.
  • .xl is for extra-large devices, screen width equal to or greater than 1200px.

The above classes can be combined to create very dynamic and flexible layouts.

Let’s look at some of the other new features in version 4. These are my selections, so if you don’t like the flavor, head over to the Bootstrap website and pick some other goodies.


One thing that version 3 was missing was the ability to add borders to HTML objects. It was possible to use the .table-bordered class on a table, but that was all. Version 4 offers a whole new set of classes that can add borders to almost anything in a very rich and flexible way.

You have the ability to both add and subtract borders, and you can add borders with colors and radius and combine the lot all by using a few classes. However, one thing you can’t do is control the width of the borders. If you want to do that, you will have to create a class yourself.

If you want to add a border to a <div> tag, simply add the class .border and you’re done. If you for some reason do not want a border on the bottom of the <div>, you can remove it by adding the classes .border .border-bottom-0. So the .border adds four borders and the .border-bottom-0 subtracts the bottom border. Very easy and neat if you ask me.

Below is a code example where I have used all the different classes in various ways to show you the border layout. Make a copy of the code and then try combining the different classes to get a feeling for this very strong feature.

Please notice this part of the code:

.boot-box-border-width {

      border-width:2px !important;


The “boot-box-border-width” class I created is how you can control the width of the borders.

<!doctype html>

<html lang="en">



        <title>MCpressonline.com -> Bootstrap 4 - Borders</title>

        <!-- Required meta tags -->

        <meta charset="utf-8">

        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


        <!-- Latest compiled and minified CSS -->

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

        <!-- jQuery library -->

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

        <!-- Popper JS -->

        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>

        <!-- Latest compiled JavaScript -->

        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>        



.boot-box {

        width: 250px;

        height: 100px;

        margin-bottom: 15px;

        background-color: #fff;


.boot-box-border-width {

        border-width:2px !important;





<div class="container-fluid">


<h4>MCpressonline.com -> Bootstrap 4 - Borders</h4>


<div class="row">

   <div class="col">

               <strong>Border - Additive</strong>



   <div class="col">

               <strong>Border - Subtractive</strong>



   <div class="col">

               <strong>Border - Colors</strong>



   <div class="col">

               <strong>Border - Radius</strong>




<div class="row">

   <div class="col">

               <div class="boot-box border">class: border</div><br>

               <div class="boot-box border-top">class: border-top</div><br>

               <div class="boot-box border-right">class: border-right</div><br>

               <div class="boot-box border-left">class: border-left</div><br>

               <div class="boot-box border-bottom">class: border-bottom</div><br>

               <div class="boot-box border-bottom border-right">class: border-bottom, border-right</div><br>




   <div class="col">

               <div class="boot-box" style="background-color:#fff"></div><br>

                <div class="boot-box border border-top-0">class: border border-top-0</div><br>

               <div class="boot-box border border-right-0">class: border-right-0</div><br>

               <div class="boot-box border border-left-0">class: border border-left-0</div><br>

               <div class="boot-box border border-bottom-0">class: border border-bottom-0</div><br>

               <div class="boot-box border border-bottom-0 border-right-0">class: border border-bottom-0 border-right-0</div><br>     



   <div class="col">

               <div class="boot-box boot-box-border-width border border-primary">class: border border-primary</div><br>

               <div class="boot-box boot-box-border-width border border-secondary">class: border border-secondary</div><br>

               <div class="boot-box boot-box-border-width border border-success">class: border border-success</div><br>

               <div class="boot-box boot-box-border-width border border-danger">class: border border-danger</div><br>

               <div class="boot-box boot-box-border-width border border-warning">class: border border-warning</div><br>

               <div class="boot-box boot-box-border-width border border-info">class: border border-info</div><br>

               <div class="boot-box boot-box-border-width border border-light">class: border border-light</div><br>

               <div class="boot-box boot-box-border-width border border-dark">class: border border-dark</div><br>

               <div class="boot-box boot-box-border-width border border-white">class: border border-white</div><br>



   <div class="col">

               <div class="boot-box boot-box-border-width border border-primary rounded">class: rounded</div><br>

               <div class="boot-box boot-box-border-width border border-primary rounded-top">class: rounded-top</div><br>

               <div class="boot-box boot-box-border-width border border-primary rounded-left">class: rounded-left</div><br>

               <div class="boot-box boot-box-border-width border border-primary rounded-right">class: rounded-right</div><br>

               <div class="boot-box boot-box-border-width border border-primary rounded-bottom">class: rounded-bottom</div><br>

               <div style="height:250px" class="boot-box boot-box-border-width border border-primary rounded-circle">class: rounded-circle</div><br>







To see the example in real life, click here.


Another set of classes provided with Bootstrap 4 offers the ability to add spacing to an element. To get the desired effect, you combine a set of letters and a number from 1 to 5.

The syntax is like this: {property}{sides}-{size} for xs and {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.

Where property is one of:

  • m—Sets margin
  • p—Sets padding

Where sides are one of:

  • t—Sets margin-top or padding-top
  • b—Sets margin-bottom or padding-bottom
  • l—Sets margin-left or padding-left
  • r—Sets margin-right or padding-right
  • x—Sets both padding-left and padding-right or margin-left and margin-right
  • y—Sets both padding-top and padding-bottom or margin-top and margin-bottom
  • blank—Sets a margin or padding on all four sides of the element

Where size is one of:

  • 0—Sets margin or padding to 0
  • 1—Sets margin or padding to .25rem (4px if font size is 16px)
  • 2—Sets margin or padding to .5rem (8px if font size is 16px)
  • 3—Sets margin or padding to 1rem (16px if font size is 16px)
  • 4—Sets margin or padding to 1.5rem (24px if font size is 16px)
  • 5—Sets margin or padding to 3rem (48px if font size is 16px)
  • auto—Sets margin to auto

So, let’s say you want to add some padding to the top of a div box and you want to have 1.5rem but only for large displays. That’s not too hard. Your class will look like this:


Here’s an example:

<div class="boot-box border pt-lg-4">


You better leave my kitten all alone,

You better leave my kitten all alone.

But I told you big fat bulldog,

You better leave her alone.

You better leave my kitten all alone,

You better leave my kitten all alone.

This dog is gonna get you

If you don't leave her alone.



To see the example in real life, click here. Try resizing the browser window to see the padding being added to the top of the div. Also try changing the class to something different to see how spacing works.


You can also control width and height very easily in version 4.


Width is controlled by the following classes:

  • w-25
  • w-50
  • w-75
  • w-100

These will set the width to the current figure in a percentage relative to its parent.

Here’s an example:

<div class="boot-box border">

      <div class="w-25 pl-1" style="background-color: #FFFF99;">25%</div>

      <div class="w-50 pl-2" style="background-color: #FFFF99;">50%</div>

      <div class="w-75 pl-sm-3" style="background-color: #FFFF99;">75%</div>

      <div class="w-100 pl-lg-4" style="background-color: #FFFF99;">100%</div>


To see the example in real life, click here. As you can see, I added some spacing to the example too. Try resizing the window to see it function.


Height is controlled by the following classes:

  • .h-25
  • .h-50
  • .h-75
  • .h-100

Here’s an example:

<div class="boot-box1 border">

<div class="h-25 d-inline-block boot-height">25%</div>

<div class="h-50 d-inline-block boot-height">50%</div>

<div class="h-75 d-inline-block boot-height">75%</div>

<div class="h-100 d-inline-block boot-height">100%</div>


To see the example in real life, click here.

Note the d-inline-block class used in this example. This is a wrapped-up CSS “display” property that controls the display behavior of an element. The display property has a lot of parameters and an explanation is beyond the scope of this TechTip, but this link will show and explain.

The First Look Is Now Over

I hope this first scratch on the surface gives you an idea of what’s inside Bootstrap 4. In my next TechTip, I will dig more into the refresh of the Bootstrap grid system, which is useful when you must adapt to Steven’s and everybody else’s need to show you data on their cell phones.

Till then, be responsive, think mobile, and keep humming those old Beatles songs.




Jan Jorgensen

Jan Jorgensen is one of the owners of www.reeft.dk, which specializes in mobile and i5 solutions. He works with RPG, HTML, JavaScript, Perl, and PHP. You can reach him at This email address is being protected from spambots. You need JavaScript enabled to view it.




Support MC Press Online

$0.00 Raised:

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: