The height of the Bootstrap column does not extend to its full potential

Having an issue:

https://i.sstatic.net/L45Ii.png

In the image, you can see that the column is not taking up the full height. The left side shows what I currently have, and the right side shows what I want to achieve. Here's the source code that corresponds to the image on the left.

Answer №1

This particular inquiry mirrors previous questions found on Stack Overflow, such as this one and that one. However, the convoluted Bootstrap grid structure you've employed is causing difficulty in achieving the desired height.

If you follow the advice provided in your other posts to simplify the markup, then resolving the height issue becomes straightforward by utilizing the flexbox grow and shrink utilities, as outlined in the Bootstrap documentation...

"Use .flex-grow-* utilities to toggle a flex item’s ability to expand and occupy available space."

Implementing classes like vh-100, flex-grow-0, flex-grow-1, flex-column, etc...

<div class="container-fluid d-flex flex-column vh-100">
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        ...
    </nav>
    <div class="row flex-grow-1">
        <div class="col-md-4 bg-warning">
            <!-- content for the left side -->
        </div>
        <div class="col-md-8 bg-primary d-flex flex-column flex-grow-1">
            <div class="row flex-column flex-fill">
                <div class="col bg-success flex-grow-0">
                    <div class="row">
                        <!-- ideally should occupy full width but currently an unwanted scrollbar appears due to this section... -->
                    </div>
                </div>
                <div class="col bg-info flex-fill">
                    <!-- Intended for central placement and occupying full screen (resembling a chat interface)--> Message </div>
                <!-- positioned at the bottom of the screen similar to conventional chat interfaces-->
                <div class="col bg-success flex-grow-0"> Text Input and Button </div>
            </div>
        </div>
    </div>
</div>

Check out this demonstration on Codeply

Answer №2

To achieve this layout, utilize the display: flex property and ensure to specify a height: 100% to cover all available height.

I have made adjustments to some classes and included new ones as needed.

For a comprehensive example, check out this stackblitz demo

Here's an instance:

<div class="box">
    <div class="row box m-0">
      <div class="col-md-12 p-0 foo-flex">
          <div>
          <nav class="navbar navbar-expand-lg navbar-light bg-light">
              <a class="navbar-brand" href="#">
                  Navbar w/ text
        </a>
              <button
                  class="navbar-toggler"
                  type="button"
                  data-toggle="collapse"
                  data-target="#navbarText"
                  aria-controls="navbarText"
                  aria-expanded="false"
                  aria-label="Toggle navigation"
              >
                  <span class="navbar-toggler-icon"></span>
              </button>
              <div class="collapse navbar-collapse" id="navbarText">
                  <ul class="navbar-nav mr-auto">
                      <li class="nav-item active">
                          <a class="nav-link" href="#">
                              Home <span class="sr-only">(current)</span>
                          </a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link" href="#">
                              Features
              </a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link" href="#">
                              Pricing
              </a>
                      </li>
                  </ul>
                  <span class="navbar-text">Navbar text with an inline element</span>
              </div>
          </nav>
          </div>
        <div class="container-fluid foo-flex-item">
          <div class="row h-100">


            <div class="col-md-4 bg-warning">
                      <div>
                <div class="row m-1">
                  <div class="col-md-11">
                    Chats
                </div>
                  <div class="col-md-1">
                    <i class="fas fa-plus-circle"></i>
                  </div>
                </div>
                <div class="row mb-2">
                  <div class="col-md-12">
                    <form class="form-inline" style="height: 0%; width: 100%; paddingLeft: 0; paddingRight: 0; paddingTop: 8px;">
                      <input class="form-control mr-sm-1" style="width: 80%;" type="search" placeholder="Search" aria-label="Search" />
                      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
                    </form>
                  </div>
                </div>
                <div class="row">
                  <div class="col-md-12">
                    <div class="list-group">
                      <div>
          <a href="#" class="list-group-item list-group-item-action flex-column align-items-start" style="7.5px; marginBottom: 7.5px;">
              <div class="d-flex w-100 justify-content-between">
                  <h5 class="mb-1">List group item heading</h5>
                  <small>3 days ago</small>
              </div>
              <div class="row">
                  <div class="col-md-11">Donec id elit non mi porta...
                  </div>
                  <div class="col-md-1">
                      <span class="badge badge-primary badge-pill text-right">5</span>
                  </div>
              </div>
          </a>
      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-md-8 bg-primary">
                <div>
          <div class="row">
              <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                  <div class="row">
                    <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
                        <div class="row">
                            <div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
                                <img src="..." class="image-head-chat" alt="Responsive image" />
                            </div>

                            <div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8">
                                Text
                            </div>

                            <div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2">
                                Icons
                            </div>
                         </div>
                      </div>
                  </div>


                  <div class="row">
                      <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
                      Message
          </div>
                  </div>

                  <div class="row">

                      <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 bg-success">
                          Text-Input and Button

                      </div>
                  </div>

              </div>
          </div>
      </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  
  

  <!-- <script src=" index.js"></script> -->
  <link rel="stylesheet" type="text/css"
    href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
  <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js">
  </script>

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

Implement a smooth transition effect when changing the image source

I am currently working on enhancing a Squarespace website by adding a new image fade-in/fade-out effect when the mouse hovers over one of three buttons. The challenge I'm facing is that the main static image is embedded as an img element in the HTML r ...

Issues with the alignment of card-footer in Bootstrap 5 card components

Looking to enhance the website for the electronics store I am employed at, I have encountered a challenge while constructing cards using Bootstrap 5. Initially, the cards varied in height until I managed to resolve the issue by setting the card height to 1 ...

JavaScript: Conditional statement used to determine the target of a touched element

I'm currently working on enhancing the mobile responsiveness of a React project. As part of this process, I am attempting to ensure that certain JavaScript-driven style changes are only applied to elements that are not the target or a child of: <d ...

After fetching an HTML snippet using the $.get() method, Font Awesome icons are no longer visible

Experimenting with creating a seamless 'single-page' experience, I've managed to achieve this by implementing an event listener in jQuery for menu link clicks. This triggers the replacement of the existing content in my main div with an HTML ...

What is the best way to eliminate all hover effects on smaller devices?

What is the solution to remove hover effects on elements in CSS? Consider the following HTML and CSS code: @media (max-width: 1220px) { .column { width: 200px; } .para { display: none; } .link:hover { color: red; } } @media (ma ...

Adjust the translateX value and element size based on either the parent element's size or the window's dimensions

Is this question specific enough to relate to others' problems? My issue involves two elements, a child and a parent, with the child element rotating around the parent using CSS animations. <div class="planet"> <div class="moon"></di ...

Retrieve information from a database based on user input keywords utilizing PHP and SQL

I have been exploring ways to allow users to enter keywords via HTML forms and then use this information to retrieve the relevant data from a database using PHP and SQL. So far, I have only been able to display data from the database using a static SQL qu ...

Implement the color codes specified in the AngularJS file into the SASS file

Once the user logs in, I retrieve a color code that is stored in localstorage and use it throughout the application. However, the challenge lies in replacing this color code in the SASS file. $Primary-color:#491e6a; $Secondary-color:#e5673a; $button-color ...

Display a jQuery loading window

Need help with displaying a loading div when making an ajax post request. I've tried the following code but it's not working. Can someone please assist in resolving this issue? $(document).ready(function() { $('a.pagerlink').click( ...

Iterating through a nested array in order to dynamically generate elements using JavaScript/jQuery

Seeking assistance with a specific issue I am facing. Despite extensive research on this platform, I have not found a solution to my problem. Recently, I successfully used jQuery each to loop over objects. However, I am currently struggling to iterate thro ...

Is there a solution to move my navbar that is frozen halfway on the screen?

I'm in the process of developing a website and have implemented a sticky navbar using CSS. However, I've noticed that when I scroll down, the navbar appears to be "stuck" slightly further down the page (as shown in the second image). Can anyone p ...

Tips for including HTML tags in strings without causing issues with nested tags

I am struggling with a string that contains both text and HTML tags, specifically <a href=""></a> tags. My goal is to apply the "i" tag around the text outside of the "a" tags without creating nested tags like: <i><a href=""></a ...

Reactjs error: Invariant Violation - Two different nodes with the matching `data-reactid` of .0.5

I recently encountered a problem while working with Reactjs and the "contentEditable" or "edit" mode of html5. <div contenteditable="true"> <p data-reactid=".0.5">Reactjs</p> </div> Whenever I press Enter or Shift Enter to create ...

What is behind the peculiar reaction when checkboxes are used in React?

In this demo, what is causing the button to disable only after both checkboxes have been checked? Is the button not initially displayed as disabled due to the way state behaves in react? The example consists of two checkboxes: I have read and agree to te ...

The color of the bootstrap button appears incorrect on Chrome browser (Mac) for some reason

I was in need of a grey color for my button, so I opted for the Bootstrap button which helped me achieve my desired look. However, an issue arose when viewing it on Chrome on a Mac system - it displayed a white background instead of grey. Can someone prov ...

I've been attempting to align the iframe element in the center without success, despite trying out various solutions from

Despite trying to center-align the div using style="text-align: center;", display: block, and align="center", none of these methods seemed to work for me. Here is the code including all attempts: <div align="center" style="text- ...

Linkify Method appearing in html.erb file displaying with HTML on the view

Apologies if this question seems basic, but I am encountering an issue when calling the following method on the @page instance variable. The view is displaying HTML tags instead of the desired content... module PagesHelper def linkify_page page rege ...

Angular Material: Enhanced search input with a universal clear button

After searching for a cross-browser search control with a clear button similar to HTML5, I found the solution rendered by Chrome: <input type="search> The code that gave me the most relevant results can be found here. I used the standard sample w ...

Troubleshooting Bootstrap Column Display Issues on Mobile Devices

I used bootstrap columns to organize my users' information. While they look good on larger screens like laptops and desktops, on smaller phone screens the second column appears to have some excess margin at the top. How can I fix this issue? <div ...

Troubleshooting: Issues with jQuery animate() not functioning properly when adjusting CSS

Currently, I am experimenting with jQuery's .animate() function to change the background of a div when it is scrolled more than 100 pixels down a page. Previously, I had successfully used .css() for this purpose. JS: $(window).scroll(function () { ...