If you’re looking to add some versatility and efficiency to your Bootstrap 3 projects, you’re in the right place. Bootstrap 4 utilities can easily spice up your designs without requiring a complete overhaul of your existing architecture. In this guide, we’ll first walk through the installation process, then dive into usage examples that show how to implement these utility classes effectively.
Installation
Getting started is incredibly straightforward. Simply download the project and include the CSS file in your project. For those of you who love customization, you can also integrate the LESS files into your project to create your own enhanced utility classes.
<html>
<head>
<link rel="stylesheet" href="bootstrap-4-utilities.min.css">
</head>
Usage
Once you’ve included the stylesheet in the <head> of your document, start leveraging the utility classes as needed. The classes are organized into three primary categories: Float, Text Align, and Spacing. Each category is further divided into Common and Responsive classes.
Understanding Utility Classes: An Analogy
Imagine your website as a fast food restaurant. The utility classes are like a menu of ingredient options that can help you craft the perfect burger (your layout). When you are assembling a burger, you might choose different ingredients based on the customer’s taste (screen size). For instance:
- Float: This represents the placement of items on your burger bun—lettuce on the left, tomatoes on the right. Using classes like
.float-leftor.float-rightdirects how toppings should be arranged. - Text Align: Think of this as how you want the burger’s name to be presented on the sign—left-aligned, center-aligned, or right-aligned. It’s all about presentation!
- Spacing: Similar to how you adjust the size of your burger by adding/removing ingredients; spacing classes allow you to add margins and padding for a balanced look.
Float Classes
To control the float on elements, use the utility classes. Common float classes include:
<div class="float-left">Float left on all viewport sizes</div>
<div class="float-right">Float right on all viewport sizes</div>
<div class="float-none">Don't float on all viewport sizes</div>
Responsive Float Classes Examples:
<div class="float-sm-left">Float left on viewports sized SM (small) or wider</div>
<div class="float-md-left">Float left on viewports sized MD (medium) or wider</div>
<div class="float-lg-left">Float left on viewports sized LG (large) or wider</div>
Text Alignment Classes
Easily align text using:
<p class="text-left">Left aligned text on all viewport sizes.</p>
<p class="text-center">Center aligned text on all viewport sizes.</p>
<p class="text-right">Right aligned text on all viewport sizes.</p>
Responsive Text Alignment:
<p class="text-sm-left">Float left on viewports sized SM (small) or wider.</p>
<p class="text-md-left">Float left on viewports sized MD (medium) or wider.</p>
Spacing Classes
Assign responsive-friendly margin or padding values:
<div class="mt-0">Margin top 0 on all viewport sizes</div>
<div class="ml-1">Margin left .25rem on all viewport sizes</div>
<div class="px-2">Padding left and right .5rem on all viewport sizes</div>
Troubleshooting
If you encounter issues with the utility classes not showing as expected, consider the following troubleshooting steps:
- Make sure that the CSS file is correctly linked in your document’s
<head>. - Confirm that you are using the appropriate class names, as typos can occur.
- Double check that there are no conflicting styles in your other CSS files.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
Adding Bootstrap 4 utility classes to your Bootstrap 3 projects is a breeze! This can transform your designs while making them more responsive and adjustable. Embracing these utilities provides enhanced styling options without complicating your layout.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Further Reading
For more information, you can check out the following links:

