Is it possible to ensure a div occupies all available space within a column using the vh-100 class in bootstrap?

In the

<div class="bg-primary"></div>
element, I'm trying to make it take up the remaining empty space without exceeding the vh-100. I've experimented with various solutions but haven't been able to find a fix yet.

body {
  margin: 0;
  padding: 0;
}
img {
  width: 336px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/css/style.css" />
    <!-- bootstrap -->
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b1914140f080f091a0b3b4e5548554b561a170b131a48">[email protected]</a>/dist/css/bootstrap.min.css"
    />
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a3835352e292e283b2a1a6f7469746a773b362a323b69">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
    <!-- font aweseome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <!-- favicon -->
    <link rel="icon" type="image/x-icon" href="/img/favicon.png" />
    <title><%= title %></title>
  </head>
  <body>

<section style="background-color: #f9f9f9">
  <div class="container-fluid">
    <div class="row">
      <!-- Navbar -->
      <!-- ! -->
      <div
        class="navbar col-2 d-flex vh-100 flex-column"
        style="background-color: #ffff"
      >
        <div class="container">
          <a href="" class="navbar-brand mt-3 mb-4">
            <img src="/img/no-bg.png" alt="" class="img-fluid" />
          </a>

          <div class="navbar-nav">
            <a
              class="nav-link my-2 text-secondary-emphasis"
              aria-current="page"
              href="#"
            >
              <i class="fa-solid fa-house"></i> Home</a
            >
            <a class="nav-link my-2 text-secondary-emphasis" href="#"
              ><i class="fa-solid fa-wallet"></i> Balance</a
            >
            <a class="nav-link my-2 text-secondary-emphasis" href="#"
              ><i class="fa-solid fa-arrow-right-arrow-left"></i> Transaction</a
            >
            <a class="nav-link my-2 text-secondary" href="#"
              ><i class="fa-solid fa-gear"></i> Settings</a
            >
            <a class="nav-link my-2 text-secondary" href="#"
              ><i class="fa-solid fa-circle-info"></i> About Us</a
            >
          </div>
        </div>
      </div>
      <!-- End of Navbar -->
      <!-- ! -->
      <div class="col-10 vh-100">
        <div class="col-12 d-flex justify-content-end py-2 align-items-center">
          <img
            src="/img/default.png"
            alt="profile pic"
            class="rounded-5"
            style="height: 35px; width: 35px"
          />
          <h6 class="px-2" style="margin: 0">Fahchouch Mohammed</h6>
        </div>
        <h2 class="my-3">Dashboard</h2>

        <!-- Cards -->
        <div class="row g-1">
          <!-- First card -->
          <div class="col-3 card text-bg-primary p-3 rounded-4 mx-4">
              ...
          </div>
          <!-- Second Card -->
              ...
          </div>
          <!-- Third card -->
              ...
          </div>
        </div>
        <!-- End Cards -->
        <div class="bg-primary"></div>
      </div>
    </div>
  </div>
    
</body>
</html>

Answer №1

Transform the vh-100 element into a vertical flex layout, and use flex-grow to expand the bg-primary element to occupy the remaining space:

body {
  margin: 0;
  padding: 0;
}
img {
  width: 336px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
... (content continues)

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

When you have a target element that is deeply nested, consider using a 50% height relative to

There is some confusion surrounding the issue below: <div class="container"> <div class="row"> <div class="group"> <a> <div class="col-lg-3 full-h"></div> </a> <a> < ...

Trouble with meta og:image on my SSL-secured WordPress site

Having some trouble adding meta properties to my WordPress website that is SSL certified. When I share the link on Skype and WhatsApp, the og:image is not working. I've tried multiple plugins and even directly added HTML code to my WordPress theme hea ...

Submenu in submenu not registering CSS hover events

Currently, on a website project that I'm developing, there is a submenu nested within another submenu. Interestingly enough, the level-2 submenu happens to be taller than its parent level-1 submenu. To control the visibility of these submenus, I' ...

How can a form be submitted in Extjs without using ajax?

Hello there! I'm attempting to submit an extjs form without using ajax and display the result on the next page. Below is my code: Ext.define('test.from', { extend: 'Ext.form.Panel', alias: 'widget.test.form', ...

Preventing navigation without using the <Prompt> component in React Router DOM V6

I have recently discovered that in react-router-dom v5, it was possible to utilize the <Prompt> component to prompt the user before a page transition occurs, allowing them to prevent it. However, this feature has been removed in v6 with plans for a m ...

How can I ensure that VueJS only starts loading data after the initial API call has been completed?

After retrieving data from an API, I populate a form in my component. The challenge I am facing is that the watchers are triggered immediately after populating the initial data. I want them to be triggered asynchronously. Additionally, I need to prevent th ...

Is it possible to open one collapse item and simultaneously close all the others using Bootstrap 5?

Can someone explain how to properly use the Bootstrap 5 collapses component? I want it so that when one collapse item opens, all others close. The documentation mentions setting a parent attribute, but I'm not entirely sure how that works. Here's ...

Rearrange HTML list items automatically according to changes in numeric sort order

I am working on a web page that features a dynamic ranked list. The items in the list are assigned a specific rank order number which changes based on user interactions elsewhere on the page. I have been exploring different options to automatically reorgan ...

Tips for displaying a refresh indicator while making an ajax call for refreshing data:

I have successfully implemented jQuery code that refreshes a specific div every 10 seconds without reloading the entire page. However, during this refresh process, the user does not visually perceive any changes happening in the browser. While there are n ...

Utilizing jQuery time intervals within a jQuery click event: A step-by-step guide

For my dropdown menu project, I am facing an issue where the menu bar is not reappearing after collapsing the dropdown. It seems that the jQuery function responsible for toggling classes within a time interval is not executing properly. Specifically, the " ...

When using JSON stringify, double quotes are automatically added around any float type data

When passing a float data from my controller to a JavaScript function using JSON, I encountered an issue with quotes appearing around the figure in the output. Here is the JS function: function fetchbal(){ $.ajax({ url: "/count/ew", dataType: "jso ...

Instructions for adding a unique custom external CSS link, such as Bootstrap CSS, to a specific REACT component

Is it possible to incorporate custom CSS from the Bootstrap website into a React component? Since this CSS file cannot be imported directly, what steps should I take to include it? <link href="https://getbootstrap.com/docs/4.5/dist/css/bootstrap. ...

Various image resolutions designed for extra small, small, medium, and large screens

My image has a relative width and currently the src points to a single, large file (approximately 1000px). The issue arises on small devices with Opera and IE where the browser scaling results in pixelated images. Conversely, using a smaller image leads to ...

Retrieving outcome of Solidity contract function using web3-1.0.0-beta.27

I am using web3 1.0.0-beta.27 and the pragma solidity is set to ^0.4.2. contract Charity{ function ping() public constant returns (uint) { return 200; } } Currently, I am compiling and calling it in typescript with: import * as fs ...

How can a CSS class be inherited from a different file?

I have defined a class for styling a button: .client-header button { /*Properties*/ } And I also have a class to indicate when the menu is open: .client-menu-open { /*Properties*/ } My goal is to change the background of the button depending on ...

Retrieving a targeted data point from a JSON object

I am working with a json data that contains various properties, but I am only interested in extracting the uniqueIDs. Is there a way to retrieve ONLY the uniqueID values and have them returned to me as a comma separated list, for example: 11111, 22222? (I ...

What is the right height and width to use in CSS?

I find it challenging to decide when to use rem, em, px, or % in web design. Although I know the definitions of each unit, I struggle with knowing the appropriate situations to utilize them. What guidelines should I follow to determine which one to use? ...

Add fresh material to the bottom of the page using Javascript

Hey there, I'm having a bit of trouble with my page where users can post their status. I want the new posts to appear at the bottom after the older posts when the user presses the button. Currently, Ajax is placing all new posts at the top of the old ...

Trimming data from model fields in a Node.js application before saving to a PostgreSQL database

While working on my node.js project, I am utilizing the objection.js ORM. So far, everything has been running smoothly. However, I'm looking to implement a feature that will trim all the fields before saving the data in the PostGres database table. In ...

How can a JQuery function be used with SVG to trigger a second animation immediately after the first animation is finished?

For the handwriting effect animation, I utilized the animation-delay technique by dividing the object wherever it intersected, drawing paths, and converting them into clipping masks. This involved breaking the letter "W" into four parts, creating different ...