Creating equal height nested columns in Bootstrap 3 Grid: ensuring all nested columns are uniform in height

Struggling to make sure all columns in Bootstrap 3 are the same height throughout the page?

If you've managed to achieve this with 3 columns, like the example provided here, great job!

However, the challenge arises when dealing with nested columns that need to occupy a certain percentage of their parent column's height. Finding a solution for nested columns seems tricky.

The goal is for nested columns to fill their parent container based on a specified percentage height set by CSS using jQuery .css()

.row {
    display: table;
}

.row [class*="col-"] {
    float: none;
    display: table-cell;
    vertical-align: top;
}

<div class="container">
<div class="row">
  <div class="col-sm-3 ">
    <img src="http://placehold.it/250x450">
  </div>
  <div class="col-sm-3 " style="background-color: grey">
    <div class="row">
      <div class="col-sm-12 " style="background-color: green">30%</div>
    </div>
    <div class="row">
      <div class="col-sm-12 " style="background-color: blue">20%</div>
    </div>
    <div class="row">
      <div class="col-sm-12 " style="background-color: red">50%</div>
    </div>
  </div>
  <div class="col-sm-3 " style="background-color: grey">
    <div class="row">
      <div class="col-xs-12 " style="background-color: green">25%</div>
    </div>
    <div class="row">
      <div class="col-xs-12 " style="background-color: orange">75%</div>
    </div>
  </div>
  <div class="col-sm-3 " style="background-color: blue">
    100%
  </div>
</div>

Answer №1

One possible solution is to use the CSS property "display: flex;" on the parent element.

Answer №2

Big thanks to @Satheesh Kumar for guiding me in the right direction! Flex turned out to be exactly what I needed. If you're curious, here's a link to the end result I was aiming for:

Check it out here!

<div class="equal-height-container">
    <div class="first">
      <img src="http://placehold.it/250x450">
    </div>

    <div class="second">
      <div class="second-a">A</div>
      <div class="second-b">B</div>
      <div class="second-c">C</div>
    </div>
    <div class="third">

    </div>
  </div>



    .equal-height-container {
          max-width: 900px;
          margin: 0 auto;
          display: flex;
        }
    .first {
      background-color: #FFF;
      padding: 20px;
      flex: 1;
    }

    .second {
      background-color: yellow;
      flex: 2;
      display: flex;
      flex-direction: column;
    }

    .third {
      background-color: yellow;
      padding: 20px;
      flex: 2;
    }
    .second-a {
      background-color: #c0dbe2;
      flex: 2.5;
    }

    .second-b {
      background-color: #cdf1c3;
      flex: 1;
    }

    .second-c {
      background-color: red;
      flex: 1;
    }

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

CSS changes on child elements cause conflicts with parent hover effects

I've come across the following html code : .logo { display: inline-block; width: 30px; position: absolute; top: 50%; opacity: 0; transition: 0.6s; } .container:hover .logo { opacity: 1; transition: 0.6s; } .container:hover .pictur ...

Unable to locate the element with the specified id: <path>

I am aiming to dynamically change the fill attribute of a specific <path> element when a page loads. Here is the detailed information about the path element: <path xmlns="http://www.w3.org/2000/svg" style="fill:#ff0000;stroke:#000000;stroke-wid ...

Trouble with loading scripts after transitioning to a new page with AJAX (Barba.js)

Exploring the potential of using AJAX for smooth page transitions. Tried two different methods so far: manually coded transition from () and Barba.js approach (). With both methods, scripts work on initial load but fail to execute when navigating to anot ...

Tips for regularly retrieving information from a psql table

I have a scenario where I am retrieving data from a psql table and converting it into a JSON array to be used for displaying a time series chart using JavaScript. The data that is passed needs to be in the form of an array. Since the data in the table get ...

Is there a way to link the id selector with the item's id?

In my app, I have a list of items with buttons that can be liked. To ensure uniqueness, I am utilizing the id selector. My goal is to use the item's id and connect it to the id selector for proper distinction. How can I retrieve the id of each item a ...

VueJS fails to display table information

I am facing an issue with rendering data from my API using VueJS 2. Although the backend services are successfully sending the data, the HTML table does not display it. There are no errors shown in the debug console, and even the Vue Debug extension for Fi ...

Is it possible to execute a JavaScript function after a successful callback using Ajax.actionlink?

I'm currently using MVC5 to load images from a list using Unobtrusive Ajax.ActionLink(). Here is the code snippet I am working with: <ul class="list-group list-unstyled lists"> @foreach (var item in Model) { <li> @Ajax.ActionLink(@item.Na ...

Why isn't the page being redirected when attempting to use JavaScript with window.location and window.location.href?

Currently, I have implemented a login system on my website. The process involves triggering an ajax request to a designated PHP script upon the user clicking the submit button. This script is responsible for logging in the user and responding with the mess ...

Disappearing Act: The vanishing act of Bootstrap 4 navbar

Everything works perfectly on a large screen, but disappears when resizing. I haven't specified a height property for the navbar. Here's the Fiddle. I know this question has been asked many times before, but I have yet to find a solution that act ...

Explore the tree structure with AngularJS and populate it with data from a JSON

After utilizing the AngularJS TreeView example from this JSFiddle link, I encountered a peculiar issue. When attempting to retrieve data from a JSON file similar to the code provided, the tree structure appeared empty. Upon inspecting the $scope.roleList1 ...

Is there a mistake in the way I am creating a horizontal navigation bar?

Currently working on creating a simple navigation bar using HTML/CSS for a Java/Spring Boot project. Admittedly, my HTML/CSS skills are quite limited as you can see below. I'm aware that there might be some mistakes in my approach. Thank you in advanc ...

JavaScript detecting improper XHTML syntax

Is there an effective method to detect malformed XHTML within a string using JavaScript? Given that my page allows user-generated XHTML (from trusted users) to be inserted into the DOM, I aim to identify unclosed or overly closed tags. If found, I intend ...

Concealing anchor and span elements using CSS in Internet Explorer 7

I decided to simplify things by creating a style within the document to address my specific issue. The problem I encountered involves a row of 4 links that are designed to resemble buttons. I have chosen to hide the Next link (the 3rd item) using CSS. Whil ...

What is the purpose of applying the two unique class names (root and disabled) to the DOM in order for it to function correctly?

When it comes to customizing components using material-ui, the process can be a bit tricky. Here's how you can do it: const styles = { root: { '&$disabled': { color: 'white', }, }, disabled: {}, // This is i ...

Should scripts be replayed and styles be refreshed after every route change in single page applications (SPA's)? (Vue / React / Angular)

In the process of creating a scripts and styles manager for a WordPress-based single page application, I initially believed that simply loading missing scripts on each route change would suffice. However, I now understand that certain scripts need to be ex ...

Oops! Smarty encountered a fatal error that wasn't caught

An error occurred while processing the template file "C:\xampp\htdocs\eventos\libs\templates\teste.tpl" on line 9. The error message states: Fatal error: Uncaught exception 'SmartyCompilerException' with message &apo ...

I am able to successfully test the REST service on localhost through a browser, however, I am encountering difficulties testing it

[OperationContract] [WebGet] public string GetImageStatusByName(string name) { panonestEntities context = new panonestEntities(); var p = context.Panoramas.Where(x => x.ImageName.Equals(name)).FirstOrDefault(); if (p ...

Using a for loop in JavaScript to dynamically generate HTML content within a Django project

Do you have a unique question to ask? Version: Django version 3.0.8 This block contains my JavaScript code: fetch(`/loadbox/${message.id}`) .then(response => response.json()) .then(dialog => { let detailcontent= `<div class=" ...

Adding ids dynamically to href elements in Vue.js

As a newcomer, I am facing an issue with dynamically adding an id to my href tag. Below is the code snippet: <div class="col-md-6" v-for="Product in data"> <div class="panel panel-default" > <div class="panel-heading"> ...

Clearing all data in a form upon opening

Within a single portlet, I have organized two forms under separate tabs. What I am aiming for is that whenever I switch to tab 2, all fields within its associated form should automatically be cleared without the need for a button click. Even after attempti ...