Include a scrollbar within a Bootstrap table grid under a div with a width of 12 columns

How can I add a scrollbar to the grid below? It is using a bootstrap table inside a bootstrap col 12 div.

I have attempted to use the following CSS, but it does not apply a scrollbar, it only disrupts the columns.

divgrid.horizontal {
    width: 100%;
    height: 400px;
    overflow: auto;
}
.table {
    display: table;
    table-layout: fixed;
    width: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
    <div class="col-md-12" id="divgrid">
        <table class="table table-striped table-bordered">
            <thead class="ui-widget-header">
                <tr>
                    <th v-for="header in columns()">
                        {{header.displayName }}
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="(row,index) in datasourc">
                    <td v-for="column in columns" class="wrap-break-word" v-show="column.isVisible">
                        <span v-html="row[column.name]"></span>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

Answer №1

To make your table responsive, enclose it in a

<div class="table-responsive">
.

If adding the class directly to #divgrid doesn't do the trick, follow the wrapper instructions on the official documentation.

Note: This method is also applicable for Bootstrap version 3.

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

Use regular expressions and JavaScript to enclose a series of English letters within a wrapper

I am looking to enclose a series or cluster of consecutive English characters within a <span> tag. In simpler terms, I aim to alter the appearance of English language in my writing. Therefore, I need to identify English characters and surround them ...

Tips for placing a button on top of a Div element with overflow set to hidden?

My goal is to have a button placed over a box, but I am facing difficulty achieving this. I have experimented with z-index, grid-content, and other methods, but the button refuses to show over the box as desired. The placement of the button inside the box ...

Send back alternate HTML content if the request is not made via AJAX

Last time I asked this question, I received several negative responses. This time, I will try to be more clear. Here is the structure of a website: Mainpage (Containing all resources and scripts) All Other pages (HTML only consists of elements of that ...

Using AJAX to showcase data from a table in a database using the <select> tag but with an unfinished submit process

I am encountering an issue with my code. When I submit the value in getinv.php, it only returns a partial value. For example, when I click '2016-08-27', it only retrieves '2016'... My question is, how can I ensure that the exact value ...

Managing the AJAX response from a remote CGI script

I'm currently working on a project that involves handling the response of a CGI script located on a remote machine within a PHP generated HTML page on an apache server. The challenge I am facing relates to user authentication and account creation for ...

What is so surprising about how a div moves and changes position?

What causes images and div elements to appear jerky when in motion? <div>*</div> $(function() { var fps = 30; var a = 0; draw = function() { a += 0.001; var x = ((Math.cos(a)+1) /2) *90; var y = ((M ...

Update the attribute of the trigger in Bootstrap's Modal by using the input value from the modal

I want to capture both the modal invoker and the user input value provided in my modal. To access the invoker, I can use the following code: $('#myModal').on('show.bs.modal', function (e) { var invoker = $(e.relatedTarget); }); A ...

Attempting to modify the background color of an iFrame in Internet Explorer

I am experiencing an issue with my webpage where the iFrame is displaying with a white background in IE, while it shows up with a blue background in Firefox and Chrome. I have attempted various solutions to make the background of the iframe blue or transpa ...

Error encountered: Trying to access the 'firstname' property of an undefined element while loading a component with an inner component

form.vue <template> <div class="form-content"> <base-input type="text" id="name" v-model="name"/> </div> </template> <script> import BaseInput from 'BaseInput.vue' export default { data () { ...

Experience the dynamic expansion of a droppable div as you elegantly drop an element within

When the questions "question1" and "question2" are dragged into "questionslots," I want the "questionSlots" div to expand its size dynamically when the second question is dropped into it. This means that both questions should be accommodated and visible wi ...

What steps can I take to guarantee that both images and text adapt well to different screen sizes?

Is there a way I can organize my website to display 3 movies per row with the text centered relative to the image? Here is how it currently looks (the red box is just for reference, please ignore): https://i.stack.imgur.com/w2pgN.jpg Also, when I resize m ...

Navigating pages in tinymce editor

Currently, I have implemented TinyMCE as the editor for my PHP-based website. However, I am facing a challenge in integrating pagination within the editor. My goal is to allow users to input long content that will be displayed across multiple pages inste ...

The Boostrap filter table control seems to be malfunctioning despite using the CDN on ASP.NET CORE MVC

How can I implement column filtering in a table using Bootstrap? Here is the code I have tried: <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.3/extensions/filter-control ...

Prevent the resizing of my website on iOS devices using HTML and CSS

I'm encountering an issue with a website I developed that seems to be resizable on certain iOS devices, including the new iPhone X. I haven't been able to replicate this behavior on other standard websites. Perhaps there's a simple CSS solut ...

The anchor is ineffective (directs to the # but stays in place)

Every attempt I've made to find a solution online has failed. When I hover over the link, it directs me to the correct URL, but the page doesn't move. I'm using an up-to-date version of Chrome. Below is the code snippet: Edit: It seems tha ...

FullCalendar and VUE Integration: In need of FullCalendar view plugins

FullCalendar Troubleshooting Greetings! I've been encountering some issues while trying to run the FullCalendar plugin in my project. Strangely, it worked perfectly fine on a different server before. Here's the code snippet I'm using. I am ...

Tips for dynamically loading a Jquery plugin/script when the page changes on Vue router

After searching for solutions on this platform, I have not found any that work for my specific issue. If you want to see a working example, you can check out this demo. My project is quite straightforward - it's a one-page application with Vue handl ...

The angular2-webpack-starter kicks off with a simple static page

When starting my project using angular2-webpack-starter, the initial loading of index.html allows us to create our own components. However, in my case, I am looking to first direct users to a static page without any Angular code before clicking a button th ...

Using jQuery to upload an image onto a canvas

When dealing with certain dependencies, I found myself needing to upload images of size 670 X 525 px to the server (regardless of the original size uploaded by users). To achieve this, I decided to draw the image onto a canvas canvasContext.drawImage(0, 0 ...

Customizing the attribute of an HTML tag using EJS or jQuery

Within my express server, I am rendering a page with the following data: app.get('/people/:personID', function (req, res) { res.render("people/profile", {person: req.person }); }); Inside my profile.ejs file, I can display the data within an ...