Achieving full screen height for nested bootstrap columns in rows

I'm currently working on a project and facing some difficulties with the bootstrap layout. My goal is to have these columns occupy the full screen height. You can take a look at the current state of my code on this jsfiddle. I've set the height of all nested rows inside the columns to:

height:100%

This was the closest solution I could come up with, but what I really want is something that resembles this (please excuse my poor MS Paint skills): https://i.sstatic.net/KsoHe.png

If the link doesn't work, here's a snippet of my code:

<!DOCTYPE html>
<html lang="en">
<head>

<!-- Link to css file -->
<link rel="stylesheet" type="text/css" href="/static/main.css" mesdia="screen"/>

<!-- Bootstrap CDN-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<meta charset="UTF-8">
<title>Layout</title>
<!--<h1>Welcome to the layout</h1>
<p>Where would you like to navigate to?</p>-->
</head>
<body>

<div class="container-fluid">
<div class="row" id="navcols">

    <div class="col layoutcol">
        <div class="row layoutrow" id="LeftCol1">Row</div>
        <div class="row layoutrow" id="LeftCol2">Row</div>
    </div>

    <div class="col-sm-6 layoutcol">
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
    </div>

    <div class="col layoutcol">
        <div class="row layoutrow" id="RightCol">Row</div>
    </div>

</div>
</div>

<!--
<div class="container-fluid">
    <h1 id="test">Welcome to my page! Where do you want to navigate to?</h1>
</div>-->

Below is the CSS styling:

html,body {
height: 100%;
width: 100%;
}
.col {
background-color:lime;
}

#LeftCol1 {
background-color:blue;
height: 100%;
}

#LeftCol2 {
background-color:red;
height: 100%
}

.layoutrow{
border:solid 1px black;
}

.MidCol{
height: 100%;
}

#RightCol {
height: 100%;
}

I am seeking advice on how to achieve the desired layout. Any help will be greatly appreciated. Thank you!

Answer №1

If you're searching for a way to achieve the desired layout using CSS and Bootstrap together, you're in luck. Here's an example of what can be done:

<!DOCTYPE html>
<html lang="en">

  <head>
    <title>Grid Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <style>
    .first .first_row{
      background-color: #ff0000;
      height: 50vh;
      border:2px solid black;
    }
    .first .second_row{
      background-color: #ffff00;
      height: 50vh;
      border:2px solid black;
    }

    .second .first_row{
      background-color: #cc99ff;
      height: 20vh;
      border:2px solid black;
    }
    .second .second_row{
      background-color: #ff0066;
      height: 20vh;
      border:2px solid black;
    }
    .second .third_row{
      background-color: #0099ff;
      height: 20vh;
      border:2px solid black;
    }
    .second .fourth_row{
      background-color: #006666;
      height: 20vh;
      border:2px solid black;
    }
    .second .fifth_row{
      background-color: #000099;
      height: 20vh;
      border:2px solid black;
    }
    .third .first_row{
      background-color: #006600;
      height: 100vh;
      border:2px solid black;
    }
    </style>
  </head>
<body>
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-3 first">
        <div class="row first_row">
        </div>
        <div class="row second_row">
        </div>  
      </div>
      <div class="col-md-6 second">
        <div class="row first_row">
        </div>
        <div class="row second_row">
        </div>
        <div class="row third_row">
        </div>
        <div class="row fourth_row">
        </div>
        <div class="row fifth_row">
        </div>
      </div>
      <div class="col-md-3 third">
        <div class="row first_row">
        </div>    
      </div>    
    </div>
  </div>
</body>
</html>

Hopefully, this example serves as a helpful guide for your project.

P.S. Please disregard the specific color choices.

Answer №2

Consider organizing the inner rows within a container, like this:

<div class="col-sm-6 layoutcol">
    <div class="container-fluid">
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</div>
        <div class="row MidCol layoutrow">Row</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

The standard color code applied to an HTML button

I need to create an anchor element <a> that resembles an HTML button. However, I am struggling to find the default background color for the input type button. ...

What does the term "the selected font size" mean when defined in em units?

Exploring the query raised in this post: Why em instead of px?, the top voted response sheds light on the nature of em: The unit 'em' is not fixed but rather relative to the current font size. It varies according to the user's chosen font p ...

The Bootstrap alert refuses to close when the close button is clicked

I'm attempting to utilize a Bootstrap alert for displaying a warning. The alert automatically fades and dismisses after a period of time, but I want to provide the user with the option to manually close it. I've included jQuery and js/bootstrap.m ...

What is preventing me from successfully transferring data to a different HTML page?

While I understand that there are numerous questions related to this topic, I believe my situation is unique. I am attempting to transfer form data from one HTML file (test.html) to another HTML file (tut1.html). Essentially, my goal is to extract the dat ...

Is it possible to conceal a form field until a previous field has been completed?

Looking for a way to hide a form field until another field is properly completed? I have a divided registration form and want the second field to appear only when the first one is valid. Preferably using CSS3, with HTML5 and maybe some JavaScript if necess ...

Positioning Div at the Bottom of a Interactive Flip Card Using Bootstrap 4

My current project features a creative flip image card created using bootstrap and js. On the back of the card, there is a title, a main text body, and a few small additional pieces of information. My goal is to have these three small bits of information a ...

Tips for integrating bootstrap jquery with dynamically generated HTML in Angular2

Currently, I am in the process of dynamically creating a sidebar that can be collapsed or expanded by simply clicking the menu item. I have tried using <div [innerHtml]="function()"></div> and it works to collapse the submenus as intended. Ho ...

A guide to placing tooltips dynamically in highcharts column charts

I am encountering an issue with tooltips in Highcharts column charts. The problem arises when the series fill up my chart, causing the tooltip to be hidden below the series and cut off by the end of the div. You can see an example here: https://i.stack.i ...

Automatically wrapping and centering characters within pre tags in HTML

I decided to add a box to highlight certain queries on a specific page, rather than the entire website. In order to test out this change, I added an inline style. I found that I had to adjust the characters within the pre tags in order to make them fit ins ...

Owl caroussel - Add a numbered image counter in between the navigation buttons

Recently, I made some adjustments to the owl caroussel nav buttons "next" and "previous" by modifying lines 2966 and 2968 to resemble arrows. To further enhance it, I now plan to include a div that will feature an image counter positioned between the navi ...

Consolidate all CSS links into a single line

Within my HTML document, I currently have the following CSS links: myPage.html <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family ...

Ensure consistency in CSS3 background color transitions

There are multiple elements on the webpage with background transitions that change from one color to another: @-moz-keyframes backgroundTransition /* Firefox */ { 0% {background-color:#ff7b7b;} 33% {background-color:#7fceff;} 66% {backgr ...

Interweaving jQuery scripts

After successfully implementing a form with jQuery, I decided to add a date picker using another jQuery code. Unfortunately, the two codes clashed and now they do not work together. Here is the initial jQuery code for the form: <!doctype html> <h ...

The ReactBootstrap flexbox feature does not automatically adjust its height to match the content within

My struggle is with getting the height of this flexbox column to match that of its content. When the window width is less than 576 pixels, only one column is displayed per row. However, in this scenario, one of the columns (the teal one) ends up being too ...

Having issues with Attributes.Add() function on ASP.NET platform

After adding CSS through code behind in asp.net on page_load, it works perfectly on my local environment but fails to work on the server. Here is the code snippet for your reference: protected void Page_Load(object sender, EventArgs e) { string selec ...

Using ImageResource in ClientBundle to create an actual <img> element

Is there a way to inform ClientBundle that all images should be actual img elements instead of fake css-background images, as background images are not printed by default in IE9? ...

Personalized scroll bar within a Chrome application

I'm currently working on customizing the scrollbar for my Chrome App using CSS and I have encountered an issue with rule #2: section { overflow: auto } section::-webkit-scrollbar { width: 5px ; } Oddly enough, when I apply the second rule, Chrom ...

The getTotalLength() method in SVG may not provide an accurate size measurement when dealing with non-scaling-stroke. To obtain the correct scale of

In my current project, I am utilizing JavaScript to determine the length of a path and apply half of that length to the stroke-DashArray. However, I have encountered an issue as I am using vector-effect="non-scaling-stroke" in order to maintain a consisten ...

Tips for utilizing rowspan and colspan in BootstrapTable

I am creating a table using bootrapTable and would like to know how I can use rowspan or colspan to achieve a table layout similar to the one shown in this image: Click here for image description $table.bootstrapTable({ columns: [{ ...

Dropdown of ui-select in AngularJS is positioned behind a div element, causing

The ui-select-match and choices component seems to be hidden behind the div/form structure. This particular ui-select component is enclosed within several parent elements, including some divs and forms. It eventually renders as follows: > <ui-select ...