The concept of columns nested within columns

My goal is to create three new columns within the center column on my webpage. However, when I attempt to nest them, they end up stacking at the bottom of the center column instead of staying inside it. Is there a way for the center column to act as a background container for the other three columns?

I'm starting to wonder if I am not utilizing Bootstrap and its columns correctly. Would it be better to just create three regular divs nested inside the center column, rather than using columns?

The website I am designing has three main columns, and within the center column, I want to have three evenly spaced boxes, images, or blocks.

Currently, I am working with Bootstrap version 4.6.1.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="51333e3e25222523302111657f677f60">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container-fluid">

  <div class="row">
    <div class="bg-secondary col-sm-2">
      1
    </div>
    <div class="bg-primary col-sm-8">
      2
      <div class="row">
        <div class="bg-warning col-sm-4">
          2.1
        </div>
        <div class="bg-warning col-sm-4">
          2.2
        </div>
        <div class="bg-warning col-sm-4">
          2.3
        </div>
      </div>
    </div>
    <div class="bg-secondary col-sm-2">
      3
    </div>
  </div>
</div>

In order to achieve the desired layout, I need to figure out how to place three additional columns inside the central column (bg-primary col-sm-8): https://i.sstatic.net/ucAv6.png

Answer №1

To achieve your desired layout, you should make use of the flex utility classes.

.container-fluid {
  height: 100vh
}

.box {
 border: 5px solid red;
 padding: 30px
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cba9a4a4bfb8bfb9aabb8bffe5fde5fa">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">

<div class="container-fluid">
  <div class="row h-100">
    <div class="bg-secondary col-sm-2">1</div>
    <div class="bg-primary col-sm-8">
      <div class="row justify-content-around align-items-center h-100">
        <div class="box">2.1</div>
        <div class="box">2.2</div>
        <div class="box">2.3</div>
      </div>
    </div>
    <div class="bg-secondary col-sm-2">3</div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display the div only if the content matches the text of the link

Looking for a way to filter posts on my blog by category and display them on the same page without navigating away. Essentially, I want users to click on a specific tag and have all posts with that tag show up. Since the CMS lacks this functionality, I pla ...

Modify the displayed text according to the content of the input field in HTML

I need to update the value of an <h3> tag based on user input in an input field. Here is my current code snippet: <input id="Medication" name="Medication" size="50" type="text" value=""> <script> $(document).ready(function () { $(&apos ...

Header Blocks that are Fixed While Scrolling in fullPage.js Sections Using the "scrollOverflow: true" Feature

I am experiencing an issue where a fixed header on my website prevents scrolling through sections when hovering, specifically when the setting scrollOverflow: true is enabled. However, everything works fine and scrolling through all sections is possible w ...

Unusual spacing issue observed between <div> elements on Internet Explorer, but not on Firefox or Opera

I am facing a common question that many others may have asked before, but I haven't been able to find a solution to my specific issue. When viewing my website on FF, Opera, and IE on Windows 7, everything displays correctly. However, when using IE7 o ...

Switch Bootstrap Tab

I have successfully implemented a bootstrap tab on my webpage and it is functioning as intended. Now, I am interested in adding an additional feature to the tabs. My question is, is it possible to toggle the content area if the same tab is clicked again? ...

Preventing background style from taking precedence over backgroundColor style in React's inline styling

What causes background to take precedence over backgroundColor in React inline-style? In this scenario, the lack of a specified green background-color results in the background gradient with transparency transitioning into white rather than green within t ...

Unusual behavior encountered while attempting to reset input text using AngularJS

I'm encountering an issue with what I assumed would be a straightforward scenario. Here is the form in question: <form class="form-inline" role="form"> <div class="form-group"> <input type="text" ng-model="customerInput" size="80 ...

Having trouble accessing the input class with jQuery

When I click the "Reset To Default Settings" button in my form, I want to clear the default colors in my 4 color pickers. Each of them has an input type text field with the class anyicon-form-colorpicker. To achieve this, I locate the <a> tag and use ...

Resolving the issue of the 'Failed to load resource: net::ERR_FILE_NOT_FOUND' error

I'm encountering issues with loading my CSS in different browsers when using the "Copy Path" feature in VSCode. While everything displays correctly in preview mode within VS, none of the styles appear when pasting the path into Chrome or Edge. Below ...

What is the best way to align a group of social media icon background images in the center

Looking for assistance with centering a block of social icons on my website when viewed on a mobile browser. Here is the HTML: <div id="header-tel-no">Tel: 123456789</div> <div id="social-buttons-header"> <p><a class="social-bu ...

Is it possible to integrate Firebase Storage into a TypeScript/HTML/CSS project without the use of Angular or React?

For my project, I am aiming to create a login and register page using TypeScript. Currently, my code is functioning well even without a database. However, I would like to implement Firebase for storing user credentials so that the login process becomes mor ...

Alignment of columns within an HTML grid

I can't seem to figure out why my grid column headers are not aligning properly with the data in the grid. It's puzzling that they have the same CSS class but different sizes. Can someone please help me with this: .outer { width: 60%; heig ...

What is the best way to get this paragraph element to rise upwards?

Everything in my code is working perfectly except for the last paragraph tag. I need to position it in the center of the blue rectangle created by the div with class "defaultButtonStyle." I've tried using margin-top in the CSS without success. Any oth ...

How can I extract the value of the first element in a dropdown using Javascript?

Imagine there is a dropdown menu with an unspecified number of options: <select id="ddlDropDown"> <option value="text1">Some text</option> <option value="text2">Some text</option> <option value="text3">Some ...

Tips for creating a dynamic logo that zooms in when you hover over it

Is there a way to create a zoom effect for the logo in my navigation bar when hovering over it without using jQuery? I've tried various codes from different sources but none seem to work. The .logo class is assigned to the logo in the nav bar. Any sug ...

What is the process for creating a two-column table in Angular?

Currently, I have an Angular template code that displays the header on the left and data on the right in a top to bottom layout. <div class="panel-body"> <table class="table table-striped"> <tr ng-repeat="f in fields"&g ...

Implementing a toggleable light and dark mode feature in Bootstrap 4 with a simple checkbox

Is it possible to link a checkbox's boolean value to a table's class in order to enable dark mode when checked? I attempted the following: <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="styleshee ...

Incorporating Google Maps into Bootstrap 4.2.1 for seamless integration

I am currently attempting to incorporate a square Google Maps into BS4. The height of the row was dictated by the 480×480px image on the left, but upon inserting the map, it turned out huge and created large gaps at the top and bottom of the row. Is ther ...

Leverage the power of JavaScript validation combined with jQuery

Hello, I'm relatively new to the world of Javascript and jQuery. My goal is to create a suggestion box that opens when a user clicks on a specific button or div element. This box should only be visible to logged-in users. I have some knowledge on how ...

Change the position of a Div by clicking on a different Div using JQuery for custom movements

I have successfully managed to slide the div left/right based on the answers below, but I am encountering some issues with the top div. Here are the specific changes I am looking to make: 1. Make both brown lines thinner without affecting the animations. ...