Experiencing excessive white space at the bottom on Bootstrap 5 for larger devices

Can anyone help me with this issue I'm experiencing while using Bootstrap 5? I have noticed that there is always white space at the bottom of the large device display. Please refer to the image attached for more clarity. Does anyone know why this white space is appearing and if there are any solutions available?

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

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Hugo 0.84.0">
    <title>Pricing example · Bootstrap v5.0</title>;

<!-- Additional code removed for brevity -->

</body>
</html>

Answer №1

If you want your content to expand and occupy all available space, the key is nesting flexbox containers and specifying which child should expand using .flex-grow-1.
For this type of layout:

  • Ensure that the content is at least the size of the viewport by making the .container also have a .min-vh-100
  • Both .container and main should be .d-flex.flex-column.
  • main and .row both need to have a .flex-grow-1.
  • The .cards should be given a .h-100 to fill the height of the .row.
  • Place the buttons inside a .card-footer to align them with each other across the row.
  • To maintain some vertical spacing between the .cards when stacked, assign the .row a .g-3

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aecccfcbcad9cac8bfcceeddbda3ebe7fb93ead6feac">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<!-- Bootstrap core CSS -->


<style>
  .bd-placeholder-img {
    font-size: 1.125rem;
    text-anchor: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
  }
  
  @media (min-width: 768px) {
    .bd-placeholder-img-lg {
      font-size: 3.5rem;
    }
  }
</style>

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
      <symbol id="check" viewBox="0 0 16 16">
        <title>Check</title>
        <path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z" />
      </symbol>
    </svg>

<div class="container py-3 min-vh-100 d-flex flex-column">
  <header>
    <div class="d-flex flex-column flex-md-row align-items-center pb-3 mb-4 border-bottom">
      <a href="/" class="d-flex align-items-center text-dark text-decoration-none">
        <svg xmlns="http://www.w3.org/2000/svg" width="40" height="32" class="me-2" viewBox="0 0 118 94" role="img">
              <title>Bootstrap</title>
             ...
</script>

Answer №2

This empty space is a result of having nothing to display there. To fill it up, consider arranging the cards in a vertical stack instead of placing them side by side (use Bootstrap class .vstack, explore more about Bootstrap stacks here).

An issue arises when using Bootstrap classes like .gap-* which determine the gap between stacked blocks based on rem units. This can be problematic as it doesn't adapt according to screen height. A possible solution is creating a custom class such as .gap-big that utilizes vh for calculating the gap. Using vh allows for setting gaps relative to the screen height, ensuring a better fit regardless of the screen size.

If the white space remains too large, try adjusting the value in the code below from gap: 10vh !important; to a higher value like gap: 15vh !important;.

Below is the proposed solution - execute the snippet and click "Full page" to view.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="John Doe">
    <title>Customized Pricing Example</title>

    <link href="https://cdn.bootstrap.com/bootstrap.min.css" rel="stylesheet" integrity="sha384-12345678" crossorigin="anonymous">

    <script src="https://cdn.bootstrap.com/bootstrap.bundle.min.js" integrity="sha384-87654321" crossorigin="anonymous"></script>

    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
      
      .gap-big {
        gap: 10vh !important;
      }
    </style>

    <!-- Custom styles for this template -->
    <link href="custom-pricing.css" rel="stylesheet">
  </head>
  <body>
    <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
      <symbol id="check" viewBox="0 0 16 16">
        <title>Check</title>
        <path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>
      </symbol>
    </svg>

      <div class="container py-3">
...
</body>
</html>

Answer №3

By enclosing all elements in a col container, you are inadvertently adding excessive margins and padding due to additional classes with padding properties.

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

Adding an arrow to a Material UI popover similar to a Tooltip

Can an Arrow be added to the Popover similar to the one in the ToolTip? https://i.stack.imgur.com/syWfg.png https://i.stack.imgur.com/4vBpC.png Is it possible to include an Arrow in the design of the Popover? ...

Google Font customization causing issues with Internet Explorer 8

I am currently building a website that utilizes custom Google fonts. However, I have noticed that in IE8, the fonts are not displaying properly or only partially rendering (the left content is fine, but the right content—specifically AJAX—is not lookin ...

Adjust the transparency of a separate image within a different container by hovering over another image container

Is my goal too complex to achieve? I am attempting to create a hover effect where the opacity of artwork1 and button1 changes simultaneously when hovered over. However, I am having trouble properly labeling my elements and getting them to interact as inten ...

Troubleshooting Issue: Bootstrap 5 Navbar Dropdown Popper Functionality Not Function

I recently updated to the latest release of Bootstrap 5.3 and encountered an issue with my dropdown menu functionality. I have the necessary Bootstrap JavaScript file saved in a folder named bootstrap.js, along with the Popper script saved as popper.js. Th ...

Positioning a button beside an input field within a table row

This is how my current table layout appears. Table: https://i.sstatic.net/wcHuz.png I am attempting to position the small x button next to the input textbox. Here is the code I have written so far. <table class="table table-hover"> <thead ...

The Verdana font in Microsoft Word appears with a distinct rendering when converted to an HTML-based

I'm currently working on generating a PDF from an HTML template. Our customer provided the template they previously used in Word, and they require the font to be Verdana. The challenge I'm facing is that Verdana looks smaller and has a different ...

Chrome experiences a crash during regular expression matching operations

I have a challenge where I am attempting to validate 50 email addresses separated by commas using regex. Strangely, every time I run this operation, Chrome crashes. However, Safari seems to handle it without any issues. Below is the code snippet that I am ...

separating kids with selectors

What is the recommended method for adding borders between children of various elements within a div? In the example below, there should be borders between p,div and div,img. <div id="list"> <p>child 1</p> <div>child 2</ ...

Styling an element in CSS3 based on the status of an input checkbox

Can someone explain the purpose of using '~' in this code snippet? I came across this example in a tutorial and am curious about its significance. http://css-tricks.com/the-checkbox-hack/ I understand that it alters the styling of an element bas ...

Can the CSS of an iframe be modified if the iframe is located on a different domain?

Is it feasible to modify the CSS of an iframe if the iframe is not located on the same domain? If so, what are some ways to apply and alter CSS for this situation? Any assistance would be greatly appreciated. <iframe id="frame1" width="100%" height="35 ...

What is the best way to insert a React component or raw HTML into another React component?

Dealing with raw HTML markup returned from an AJAX call can be tricky in React. I've tried using dangerouslySetInnerHTML, but React just throws errors when I do. It's like trying to navigate through a maze. After some trial and error, I decided ...

Using div tags to organize content into rows

What is your interpretation of a row using div elements? Here is a simplified example in pseudocode: [DIV TAGS LEFT] [DIV TAGS CENTER] [DIV TAGS RIGHT] [INSERT CONTENT HERE] [DIV TAGS LEFT] [DIV TAGS CENTER] [DIV TAGS RIGHT] [INSERT CONTENT HERE] [ ...

Does the Width Toggle Animation fail to function in FireFox when using jQuery?

Has anyone else encountered this issue with the jQuery animate function not working in Firefox but working fine in IE8, Opera, and Chrome? I'm experiencing this problem and wondering if there's a workaround to make it work in Firefox as well. ht ...

How can I customize the appearance of tab buttons in a QtabWidget using PySide?

Looking for a way to customize the tab buttons on a QtabWidget in PySide. I've managed to style other elements of my custom widget, but can't figure out how to style the QtabWidget tabs. My attempt: self.tabWidget = QtGui.QtabWidget(Form) self. ...

Steps for linking two MySQL tables

I have a table named "products" in my MySqli Database. Products TABLE product_id | INT primary KEY product_name | VARCHAR(50) product_price | float When entering rows into the products table from PHP, I use the following code: mysq ...

Unexpected disappearance of form control in reactive form when using a filter pipe

Here is a reactive form with an array of checkboxes used as a filter. An error occurs on page render. Cannot find control with path: 'accountsArray -> 555' The filter works well, but the error appears when removing any character from the fi ...

Ways to access nested div children without using identifiers

To customize the width of a specific div using jQuery, I need to target the following structure in my HTML code. Although parts of it are generated by a lightbox plugin, the part that sets it apart is the unique class "xxxgallery": <div class="xxxgalle ...

Is there a way to keep left-aligned text centered even when it wraps around?

I would like to center a block of left-aligned text within a div, ensuring that the visual width of the text block is centered rather than the block itself. In situations where the div is narrow and the text is too long to fit on one line, causing it to o ...

javascript various backgrounds on click

I have implemented a list to allow users to select their top 3 choices, and I am using JavaScript to track these selections and change the background color accordingly. 1st selection -> Green background 2nd selection -> Yellow background 3rd sel ...

Arranging a list with both Left and Right alignment on a single line in proper sequence

After trying to work with a list containing 5 items, I'm having trouble getting it to display as shown in the desired image. I am new to CSS so any guidance is appreciated. #navlist li { display: inline; } #navlist #right { float: right; margin-righ ...