difficulty eliminating white space in HTML display using Bootstrap

Encountering an issue with the template view below. A scrollbar was added to the "Used in" table at the bottom, but there is excessive whitespace beneath it. Removing divs/elements one by one reveals that the problem seems to stem from the table itself.

view.html

{% extends "includes/base.html" %}

{% load crispy_forms_tags %}

{% block body %}

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

        <div class="col">

            <form method="POST">
                <br>
                {% csrf_token %}
                {% crispy partform %}
            </form>
            <br>
            <table class="table table-hover">
                <tbody>
                {% for comment in partcomments %}
                <tr>
                    <td>{{ comment }}</td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
            <form method="POST">
                <br>
                {% csrf_token %}
                {% crispy commentForm %}
            </form>
            <div>
                {% for image in images %}
                <img class="center img-responsive" src="{{ image.image.url }}"
                     style="height: 25%"/>
                {% endfor %}
                <br>
                <form enctype="multipart/form-data" method="post">
                    {% csrf_token %}
                    {{ imageform.as_p }}
                    <button type="submit">Upload</button>
                </form>
            </div>
        </div>

        <div class="col">
            <div class="table-wrapper-scroll-y my-custom-scrollbar">

                <table class="table table-hover mb-0">
                    <thead>
                    <tr>
                        <th>Supplier</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for supplier in partsuppliers %}
                    <tr data-href="{% url 'info_supplier' supplier.supplier.id %}">
                        <td>{{ supplier }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <a class="btn btn-secondary btn-sm btn-pad" href="{% url 'addpartsupplier' part_id=part_id %}"
               role="button"&g;Add
                Supplier</a>
            <div class="table-wrapper-scroll-y my-custom-scrollbar">

                <table class="table table-hover mb-0">
                    <thead>
                    <tr>
                        <th>Movements</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for movement in movements %}
                    <tr>
                        <td>{{ movement.history_date }}</td>
                        <td>{{ movement.history_user }}</td>
                        <td>{{ movement.change }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <div class="table-wrapper-scroll-y my-custom-scrollbar">
                <table class="table table-hover mb-0">
                    <thead>
                    <tr>
                        <th>Used in</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for activity in activities %}
                    <tr>
                        <td>{{ activity.group.groupName }}</td>
                        <td>{{ activity.activity.activityName }}</td>
                        <td>{{ activity.qty.quantity__sum }}</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


{% endblock %}

A custom.css file is located in the static folder and loaded in base.html as shown below. The overflow issue is specific to this view, without any problems found in other templates when base.html was removed.

custom.css

.my-custom-scrollbar
{
position: relative;
max-height: 25%;
overflow: auto;
}
.table-wrapper-scroll-y {
display: block;
}
.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

It appears that something may be missing in the CSS. Any assistance would be greatly appreciated.

Edit: An image has been included below for better clarification. There is a significant amount of white space extending to the end of the table without the y scroll.

Answer №1

When using Bootstrap, a margin-bottom of 20px is automatically applied to elements with the ".table" class. You can confirm this by inspecting the table in the console.

https://i.sstatic.net/8iu23.png

If you want to remove this default margin, you must override the style rule in your own CSS file. Remember to place this override after importing the Bootstrap styles.

.table {
    margin-bottom: 0;
}

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

What options do I have for personalizing this Google Bar Graph?

I am currently working on creating a Google bar chart. You can view my progress here: http://jsfiddle.net/nGvdB/ Although I have carefully reviewed the Google Bar Chart documentation available here, I am struggling to customize the chart to my needs. Spec ...

Having difficulty displaying closed captions on HTML5 videos

I'm currently attempting to enable closed captions for an HTML video. Here is the code I am using: <video width="320" height="240" id="video" controls> <source type="video/mp4" src="file.mp4" > <track id="video1" src="file1.srt" labe ...

Tips for adding jQuery UI styling to elements generated dynamically

I have a challenge with generating text fields using jquery while applying jquery ui styling to the form. The issue is that the dynamically created elements do not inherit the css styles from jquery ui: let index = 0; $('#btn_generate').on(& ...

Div I add to page is not being styled by CSS

I'm currently developing a Chrome extension that provides a preview of a webpage when hovering over a hyperlink to it. To achieve this, I am creating a div and filling it with different items. However, the issue I'm facing is that the CSS styles ...

Increasing the size of a div container based on the position of the cursor on the

I recently stumbled upon a fantastic website where two images slide left and right based on mouse movement. When the cursor is on the right, the right part of the image expands, and when it's on the left, the left part expands. You can check out the ...

React text hover image functionality

Just diving into the world of React and attempting to create a cool image popup effect when you hover over text in my project. I could really use some guidance on how to make it function within React, as the logic seems a bit different from plain HTML. Any ...

Creating motion in recently added elements using varied keyframe settings

I'm currently working on a simple animation project. The goal is to create a circle that appears and moves upwards when you click inside the blue container. I managed to find out how to incorporate JavaScript values into keyframes, but the issue is th ...

Is it possible to edit multiple classes simultaneously in Bootstrap?

After creating a div with the class container and adding 50px padding to the top, I am now ready to add another container using Bootstrap's CSS. Do I need to create a new class like container-2 to edit the new container's style or are there multi ...

Wagtail: Inline Panels Within Panels

Is it possible to nest an Inline panel within another Inline panel, and then place that nested Inline panel into a Snippet in Wagtail? Previous discussions indicate that Wagtail did not support this functionality: https://groups.google.com/forum/#!msg/wag ...

textarea label align: center

I've been struggling to center-align the label for this textarea within the text box, but so far my attempts have failed. The resulting display resembles the following: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx ...

Acquiring information to display in a div using innerHTML

I aim to create a div that displays different animal sounds, like: Dog says Bark Bark I've attempted various methods but I'm unable to get each pair in the array to show up in a div: const animal = [ {creature: "Dog", sound: "B ...

Ways to align an inner circle in the middle using CSS

div.container{ border:2px dashed blue; position:relative; } span.parent{ display:inline-block; width:40px; height:40px; border:2px solid black; border-radius:50%; text-align: center; position:absolute; right:20px; top:10px; } span.ch ...

How can I retrieve data for the currently logged-in user from a MySQL database in Django without explicitly setting the user ID?

I'm a beginner in programming and currently trying to learn Django and Python. Here is what I have so far: View: def dashboard(request): return render(request, 'app/dashboard.html', {'my_custom_sql': my_custom_sql}) The fun ...

Error in Angular2: Unresolved Variables

Hello world, seeking guidance, I recently started learning Angular2 and ventured into creating a simple app which is now not working! The component.ts file import {Component, OnInit} from '@angular/core'; import { Player } from './player.m ...

Reveal the hidden div by sliding it up from the bottom

I have a container with brown branches resembling the image, and I'm looking to hide it. When a button is clicked, I want it to reveal from the bottom to the top, almost like it's being unmasked. I've ruled out a typical bottom-up slide anim ...

Alter global table data attributes through device detection with Javascript

Initially, I assumed that setting the global font-size of all td's would be a simple task. However, I am having trouble finding a solution. In my existing stylesheet, I have defined the font-size for all td's. td { font-size: 20px; ...

What is the method for establishing an interval, removing it, and then reinstating the interval with the identical ID?

I'm wanting something along these lines: Inter = setInterval(Function, 1000); clearInerval(Inter); Inter = setInterval(Function, 1000); I've tried something similar without success. It's hard to explain all the details in a tidy way. Can a ...

Transferring information to an Ionic 5 custom element label

In my ionic 5 app, I have a side menu and tabs. Each page can have different contents for the side menu and the tabs. Instead of duplicating the ion-menu in each page, I created a header component (and one for the tabs) as follows: HEADER COMPONENT: <i ...

Using static typing in Visual Studio for Angular HTML

Is there a tool that can validate HTML and provide intellisense similar to TypeScript? I'm looking for something that can detect errors when using non-existent directives or undeclared scope properties, similar to how TypeScript handles compilation er ...

audio enhancement in a web-based game

I'm having trouble getting a sound effect to play consistently in my game whenever there is a hit. Sometimes the sound plays, other times it does not! Here is the code I am using: <script> var hitSound = new Audio(); function playEffectSound ...