Bootstrap snippet and html example. Bootstrap 4 Grid System Guide

Bootstrap 4.3.1 snippet "Bootstrap 4 Grid System Guide" with HTML, CSS, and JS. Copy, paste, and customize this responsive UI component for your project.

HTML code

Clean, semantic HTML that powers this Bootstrap 4.3.1 snippet. Copy and paste it into your page (with Bootstrap loaded) to reproduce the exact layout shown in the preview.





<!-- GRID SYSTEM - HTML -->

<!-- Grid System: Settings -->
<div class="grid-settings">
  <div class="card">
    <div class="card-header">Grid System Settings</div>
    <div class="card-body">
    <p class="card-text mb-2">Grid options:</p>
    <a href="#" id="show-grid" class="btn btn-block btn-sm btn-danger mb-0" type="submit">Hide Grid</a>
    <a href="#" id="show-gutters" class="btn btn-block btn-sm btn-danger mb-2">Remove Gutter</a>
      <a href="#" id="grid-theme" class="btn btn-block btn-sm btn-dark mb-2">Grid Dark</a>
      <p class="card-text mb-2">Container option:</p>
    <a href="#" id="change-container" class="btn btn-block btn-sm btn-primary mb-2" type="submit">Container Size</a>
    </div>
  </div>
</div>

<!-- Grid System: Grids -->
<div class="container grid-system">
  <div class="row">
      <div class="col-1">
        <div class="col-div">1</div>
      </div>
      <div class="col-1">
        <div class="col-div">2</div>
      </div>
      <div class="col-1">
        <div class="col-div">3</div>
      </div>
      <div class="col-1">
        <div class="col-div">4</div>
      </div>
      <div class="col-1">
        <div class="col-div">5</div>
      </div>
      <div class="col-1">
        <div class="col-div">6</div>
      </div>
      <div class="col-1">
        <div class="col-div">7</div>
      </div>
      <div class="col-1">
        <div class="col-div">8</div>
      </div>
      <div class="col-1">
        <div class="col-div">9</div>
      </div>
      <div class="col-1">
        <div class="col-div">10</div>
      </div>
      <div class="col-1">
        <div class="col-div">11</div>
      </div>
      <div class="col-1">
        <div class="col-div">12</div>
      </div>
  </div>
</div>

<!-- YOUN WON'T NEED ANY OF THESE BELOW: -->

<!-- Navbar -->
<nav class="navbar navbar-light bg-light px-0">
  <div class="container-fluid">
  <a class="navbar-brand" href="#">
    <img src="https://getbootstrap.com/docs/4.3/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top mr-3" alt="">Grid4BS
  </a>
    <span class="navbar-text">
      A visible grid system for Bootstrap
    </span>
    </div>
</nav>

<main role="main">

  <!-- Jumbotron -->
  <div class="jumbotron px-0">
    <div class="container">
      <h1 class="display-3">Hello, world!</h1>
      <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
      <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
    </div>
  </div>

  <div class="container">
    <!-- Example row of columns -->
    <div class="row">
      <div class="col-md-4">
        <h2>Heading</h2>
        <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
        <p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
      </div>
      <div class="col-md-4">
        <h2>Heading</h2>
        <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
        <p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
      </div>
      <div class="col-md-4">
        <h2>Heading</h2>
        <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
        <p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
      </div>
    </div>

    <hr>

  </div> <!-- /container -->

</main>

<footer class="container">
  <p>&copy; Company 2017-2019</p>
</footer>

CSS code

Scoped CSS that styles the component. Paste it after Bootstrap 4.3.1 to keep the design, spacing, and responsiveness consistent.





/* GRID SYSTEM - CSS */

/* Grid System: Settings */
.grid-settings {
  position: fixed; 
  width: 200px;
  top: 80px;
  right: 20px; 
  z-index: 9999; 
}

/* Grid System: Grids */
.grid-system {
  text-align: center;
  position: fixed;
  right: 0;
  left: 0; 
  margin-right: auto;
  margin-left: auto;
  height: 100vh;
  z-index: 1;
  visibility: visible;
}
.grid-system div[class^="col-"] {
    border-left: 1px dotted rgba(0, 0, 0, 0.2);
    height: 100vh;
}
.grid-system div[class^="col-"]:last-child {
    border-right: 1px dotted rgba(0, 0, 0, 0.2);
}
.grid-system .col-div {
    background-color: rgba(0, 0, 0, 0.025);
    border: none !important; 
    padding-top: 15px; 
    color: rgba(0, 0, 0, 0.3);
}

/* Grid System: Light Theme */
.grid-system.light .col-div { 
  background-color: rgba(255, 255, 255, 0.025); 
  color: rgba(255, 255, 255, 0.3);
}
.grid-system.light div[class^="col-"], 
.grid-system.light div[class^="col-"]:last-child { 
  border-color: rgba(255, 255, 255, 0.2);
}

/* FOR DEMO PURPOSES ONLY: */
.bg-dark h1, .bg-dark h2 {
  color: #fff;
}
.bg-dark p {
  color: rgba(255, 255, 255, .5);
}
.grid-settings .card-body p {
  color: #212529;;
}

Javascript/Jquery code

Lightweight JS to power any interactions this snippet needs. Drop it under your scripts (after Bootstrap 4.3.1) to mirror the live demo.





/* GRID SYSTEM - JS */

// Show - Hide Grid
$( '#show-grid' ).click(function() {
  $( ".grid-system" ).toggleClass( "invisible" ); 
  $( this ).toggleClass( "btn-danger" ).addClass( "btn-success" ); 
  $(this).text(function(i, text){
          return text === "Show Grid" ? "Hide Grid" : "Show Grid";
      })
});

// Add - Remove Gutters
$( '#show-gutters' ).click(function() { 
  $( this ).toggleClass( "btn-danger" ).addClass( "btn-success" ); 
if ($( ".row" ).hasClass( "no-gutters" ) == true) {
        $( ".row" ).removeClass( "no-gutters" ); 
  $( this ).html( "Remove Gutter" );
}
else if ($( ".row" ).hasClass( "no-gutters" ) == false) {
        $( ".row" ).addClass( "no-gutters" ); 
  $( this ).html( "Add Gutter" );
}
});

// Dark - Light Grid Theme
$( '#grid-theme' ).click(function() {
  $( ".grid-system" ).toggleClass( "light" ); 
      
      // THESE LINES ARE:
      $( ".navbar" ).toggleClass( "bg-dark" ); 
      $( ".navbar" ).toggleClass( "navbar-dark" ); 
      $( ".jumbotron" ).toggleClass( "bg-dark" ); 
      $( "body" ).toggleClass( "bg-dark" ); 
      // FOR DEMO PURPOSES ONLY!
      
  $( this ).toggleClass( "btn-dark" ).addClass( "btn-light" ); 
  $(this).text(function(i, text){
          return text === "Grid Light" ? "Grid Dark" : "Grid Light";
      })
});

// Change Container Size
$( '#change-container' ).click(function() {
if ($( ".container" )[0]){
        $( ".container" ).removeClass( "container" ).addClass( "container-fluid" ); 
}
else if ($( ".container-fluid" )[0]){ 
  $( ".container-fluid" ).removeClass( "container-fluid" ).addClass( "container"); 
}
}); 

Similar snippets

Bootstrap example and template. Get in Touch form

Get in Touch form

Bootstrap example and template. panel followers

panel followers

Bootstrap example and template. bs4 seller cards

bs4 seller cards

Bootstrap example and template. circle photo with div change color

circle photo with div change color

Bootstrap example and template. bs5 dark footer

bs5 dark footer

Bootstrap example and template. paq page

paq page

Bootstrap example and template. timeline steps

timeline steps

Bootstrap example and template. faqs page

faqs page

FAQ

How do I use this snippet?

Include Bootstrap 4.3.1, paste the HTML, add the CSS block, and include the JS (if any) to mirror the live preview.

Can I use it in commercial projects?

Yes. It’s free for personal and commercial work; check the snippets license for details.

Is it responsive?

Yes. It inherits the responsive grid and components from Bootstrap 4.3.1.

Bootstrap example and template. Bootstrap 4 Grid System Guide

About this bootstrap example/template

Optimized for copy‑paste: clean HTML, scoped CSS, and minimal JS so you can ship production‑ready UI faster and keep designs consistent.

Mobile‑first and responsive by default. Tested across modern browsers to reduce polish time on your project.

Already trusted in 494+ views. Reuse this snippet to speed up landing pages, dashboards, or onboarding flows.

Bootstrap 4.3.1

<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'>

<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js'></script>

This code example is based on bootstrap 4.3.1 and the grid system of this framework

Responsive

Based on bootstrap framework makes all the layouts perfectly responsive for all devices

Crossbrowser compatibility

Tested on all major browsers, it works smoothly on all of them

Jquery plugins

Great built-in plugins with jquery framework, you can easy to change all declarations

semantic html 5

Built on html / css3 the code quality is really amazing

Simple Integration

This code example can be simply integrated on existing sites and new ones too, all you need to do is copy the code and start working