Display the scrollbar in a Boostrap CSS table when the content exceeds the height of the div

I've been working on a Bootstrap page that looks like this:

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

On the right side, there are two tables inside a div. The issue I'm facing is that when the tables contain too many elements, they grow in height instead of showing a vertical scrollbar.

Here's what it looks like with the problem:

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

The code for this section is as follows:

<div class="container-fluid">
    <div class="row">
        <!-- ********** Tauler ********** -->
        <div id="board" class="col-sm-6 board m-3 shadow">
            <!-- Board created via JS goes here -->
        </div>
        <!-- ********** Move List ********** -->
        <div id="move-list" class="col-sm-2 m-3 bg-light shadow">
            <table class="table table-striped caption-top">
                <caption class="text-center fw-bold">List of Moves</caption>
                <thead class="table-light">
                <tr>
                    <th scope="col">#</th>
                    <th id="light-player-name" scope="col">Player 1</th>
                    <th id="dark-player-name" scope="col">Player 2</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th scope="row">1</th>
                    <td>♙f3</td>
                    <td>♟︎e5</td>
                </tr>
                <tr>
                    <th scope="row">2</th>
                    <td>♘cr</td>
                    <td>♞c6</td>
                </tr>
                <tr>
                    <th scope="row">3</th>
                    <td>♙f4</td>
                    <td>♟︎exf4</td>
                </tr>
                </tbody>
            </table>
        </div>
        <!-- ********** Online Players List ********** -->
        <div id="online-list" class="col-sm-2 m-3 bg-light shadow">
            <table class="table table-striped caption-top">
                <caption class="text-center fw-bold">List of Players Online</caption>
                <thead class="table-light">
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Username</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th scope="row">1</th>
                    <td>@username</td>
                </tr>
                <tr>
                    <th scope="row">2</th>
                    <td>@username</td>
                </tr>
                <tr>
                    <th scope="row">3</th>
                    <td>@username</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

Answer №1

To enhance the appearance of your

<table class="table table-striped caption-top">
, consider adding a custom style.

For instance, you could try

<table class="table table-striped caption-top" style="overflow-y:scroll;">

Alternatively, with bootstrap, experiment with

<table class="table table-striped caption-top overflow-auto">
.

Find more information on styling options in Bootstrap documentation: https://getbootstrap.com/docs/5.0/utilities/overflow/

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

Express Node fails to launch

I recently decided to try my hand at Express and learn more about it. However, I encountered an issue while trying to start a server. Initially, I attempted to access 127.0.0.1:8080 through Express but nothing seemed to be happening. Although I copied most ...

Is there a way to store the JWT response header retrieved with fetch?

I am currently utilizing React and employing fetch to send a request to the server: fetch("http://localhost:8001/api/login", { method: 'post', headers: { "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, ...

Angular2 - Actively selecting a checkbox in an ngFor loop with a reactive form

There is an object retrieved from a database that consists of a list of names with their corresponding IDs, as well as a flag to indicate whether they are selected or not. Object: let items = [{ ID: 1, Name: 'Item A', Selected: 'Y ...

Activate HTML event upon reaching a specific point while scrolling, and then reactivate by scrolling back

I'm encountering an issue where the fade effect triggers when I scroll past a certain point, but then fails to fade back in once I scroll back. Is my approach correct or am I missing something? Currently, it fades out abruptly at a specific point and ...

Customize CSS for Vimeo's HTML5 player

Can I customize Vimeo's HTML and CSS attributes? I have a video that autoplays and I don't want the play button. I want to modify this specific class. .a.l .b .as { position: absolute; top: 50%; left: 50%; margin: -2em 0 0 -3.25em; float: none; ...

What is the best way to import two components with the same name from different libraries?

How can I import the Tooltip component from two different libraries without encountering naming conflicts? For example: import { Tooltip as LeafletTooltip } from "react-leaflet"; import { Tooltip as RechartsTooltip } from "recharts"; By renaming the impo ...

Error in jQuery ajax request when passing multiple variables to php script

When I use ajax to send two variables to PHP, the second variable is received correctly, but the first variable is always reported as NULL by PHP. I checked the JavaScript variable before sending it and confirmed that it contains an array of strings. I&apo ...

What is the best way to retrieve the text input fields while using express-fileupload with React?

Front end Uploading a File: <div className="form-group row"> <label htmlFor="directorySSH" className="col-sm-3 col-form-label">Directory: </label> <div className="col-sm-7"> <input ty ...

The functionality of JQuery TableSorter is not responsive when a user clicks on it

I seem to be running into an issue on my website where I can't get the JQuery TableSorter to work properly. When I attach it to a table for sorting, nothing happens when I click on the headers. The table remains static and unsortable. Here's a s ...

Reversing the order of input-group-addon and input in bootstrap on mobile devices

I attempted to adjust the layout of a bootstrap input-group-addon on mobile devices by using two input elements and manipulating their display and visibility properties. From a design standpoint, I achieved the desired result as the input is now positione ...

Unable to retrieve this object because of a intricate JavaScript function in Vue.js

For my VueJs project, I am utilizing the popular vue-select component. I wanted to customize a keyDownEvent and consulted the documentation for guidance. However, I found the example provided using a mix of modern JS techniques to be quite cryptic. <tem ...

Exploring the method of displaying a JSON 2D array through the utilization of getJSON

Is there a way to read 2D JSON data? An example of a JSON file is given below: [ { "name":"Menu1", "permission":"1", "link":"http://naver.com" }, { "name":"Menu2", "permission":"2", "link":"http://daum.net", ...

A mysterious underscore suddenly materializes within Font Awesome icons when used in HTML

Currently, I'm working on the footer section of a webpage using HTML and Bootstrap 5.3.0. I encountered an issue where an underscore appears next to the icons when I add them. I suspect that this is due to the white spaces between the elements, which ...

Is there a way to determine whether a mouse-down event took place on the scroll-bar or elsewhere within the element?

Looking for a solution with my HTML div acting as a canvas containing various objects. The issue lies in the fact that when attempting to draw a selection rectangle by dragging with the mouse, if scroll bars appear due to the large size of the canvas, scr ...

Display items in a not predetermined order

Despite its simplicity, I am struggling to get this working. My aim is to create a quiz program using JavaScript. Here is the basic structure: <ul> <li>option1</li> <li>option2</li> <li>option3</li> </ul> &l ...

Choose between using Paypal or Google Checkout for your shopping cart - unfortunately, both options cannot be used

My dilemma is that I currently have a functional shopping cart that is only coded for either Paypal or Google Checkout, not both. Here is a demo of the shopping cart set up for Paypal checkout: The javascript code used in the demo can be found here: Loo ...

Animate the rotation of specific paths within the SVG

I've designed an SVG using Illustrator and I have a specific animation in mind for it. My goal is to create an animation where the upper part of the circle line rotates from left to right (considering that there are 4 circle lines, with number one st ...

Using SABA to access web services

I am looking to customize a SABA page by adding an HTML button that, when pressed, will call a web service to retrieve an answer based on input parameters and take appropriate action. The web service accepts a JSON variable as input, structured like this: ...

Animating file transfer can be achieved using either JavaScript or CSS

My goal is to create a visual representation of file transfer, such as moving a file from one folder to another. I have successfully achieved this using JavaScript with the following code: <script type="text/javascript> var img; var animateR; var an ...

The DataTable is encountering difficulties with processing JSON data retrieved from the database

Setting up a datatable on my website has been quite the challenge. I came across a table that I wanted to use here, but converting it to fit my needs has not been successful. Currently, the table is not populating with rows from a database table and I&apos ...