Issues with the panel's scroll bar functionality in an HTML document

I am currently working with Bootstrap HTML 5 where I have a panel containing a table. Although I have set scroll for the panel, the table is not adjusting properly within the panel and the scrollbar appears inactive. My goal is to ensure that each header content in the table cells does not overlap and the scrollbar becomes active when there is excessive content.

Here is the HTML code:


<div class="panel-body panel-scroll">
    <table class="table table-bordered" id="tableMyCert">
        <thead style="background-color:lightblue">
            <tr>
                <th class="col-sm-4">head 1</th>
                <th class="col-sm-3">head 2</th>
                <th class="col-sm-3">head 3</th>
                <th class="col-sm-3">head 4</th>
                <th class="col-sm-3">head 5</th>
                <th class="col-sm-5">head 6</th>
                <th class="col-sm-2">head 7</th>
                <th class="col-sm-5">head 8</th>
                <th class="col-sm-4">head 9</th>
                <th class="col-sm-2">head 10</th>
                <th class="col-sm-5">head 11</th>
                <th class="col-sm-4">head 12</th>
                <th class="col-sm-2">head 13</th>
                <th class="col-sm-5">head 14</th>
                <th class="col-sm-4">head 15</th>
                <th class="col-sm-2">head 16</th>
                <th class="col-sm-5">head 17</th>
                <th class="col-sm-5">head 18</th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
</div>

And here is the CSS code:


.panel-scroll{
    overflow-x:scroll;
    width:100%;
}

Answer №1

create a structure similar to this

<div class="table-responsive">
     <table class="table table-bordered" id="tableMyCert">
  //add your code here
    </table>
     </div>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="table-responsive">
         <table class="table table-bordered" id="tableMyCert">
                    <thead style="background-color:lightblue">
                        <tr>
                            <th class="col-sm-4">head 1</th>
                            <th class="col-sm-3">head 2</th>
                            <th class="col-sm-3">head 3</th>
                            <th class="col-sm-3">head 4</th>
                            <th class="col-sm-3">head 5</th>
                            <th class="col-sm-5">head 6</th>
                            <th class="col-sm-2">head 7</th>
                            <th class="col-sm-5">head 8</th>
                            <th class="col-sm-4">head 9</th>
                            <th class="col-sm-2">head 10</th>
                            <th class="col-sm-5">head 11</th>
                            <th class="col-sm-4">head 12</th>
                            <th class="col-sm-2">head 13</th>
                            <th class="col-sm-5">head 14</th>
                            <th class="col-sm-4">head 15</th>
                            <th class="col-sm-2">head 16</th>
                            <th class="col-sm-5">head 17</th>
                            <th class="col-sm-5">head 18</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
    
    
      </div>

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

Can CSS be used for creating unique color combinations?

I am facing a challenge where I have two div elements with different transparent, colored backgrounds that overlap each other. My goal is to find a way to customize the color in the area where these elements overlap. For instance, if I blend red and blue ...

Methods to fill a data table cell

I have recently created a table and I am facing an issue in populating the tds cells using JavaScript. The data for the table is coming from the server. Here's my table: <table id="report" class="infoRecurso" id='testExportId' style="wid ...

Encountered an error while attempting to load resource: the server returned a 404 (Not Found) status code when trying to load an image in an

I am looking to dynamically load an image when it is selected from a file picker dialog. The code provided below attempts to achieve this, however, the image does not load into the img tag. <script src="https://cdnjs.cloudflare.com/ajax/libs/jq ...

Restoring text boxes to their original styling

I've been working on a jQuery script that scans through form input elements and turns their border color to red if they are empty. When the submit button is pressed, it reassesses the elements; this time I'm trying to revert the textbox back to i ...

Unable to access Form element in Firefox browser

I'm struggling with debugging unfamiliar problems. For instance, in my HTML there's a form: <form name="myForm" > <table> <tr> <td> <input type="radio" name="myType" value="val" onclick="someF ...

Dealing with problematic hover behaviors in Cypress: A guide

I encountered an issue with Cypress hover functionality while trying to access a sub menu that appears after hovering over a main menu item. The error message I received was This element is not visible because it has CSS property: position: fixed and it&ap ...

Trigger a change event for a Material Checkbox by referencing its unique identifier

<div *ngFor="let cus of deselectedList | keyvalue" (click)="clickCheckBox('customer_'+cus.key+'_checkbox')"> {{cus.key}} <mat-checkbox id="customer_{{cus.key}}_checkbox" (change ...

Save information in a session using html and javascript

I'm having trouble accessing a session variable in my javascript code. I attempted to retrieve it directly but ran into issues. As an alternative, I tried storing the value in a hidden HTML input element, but I am unsure of how to properly do that wit ...

Designing materials involves organizing 5 items in a section, as dividing 12 by 5 results in an unattractive

Incorporating the Material Design Light library into my webpage, I have a section with 5 items that I want to evenly occupy the space: <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp social-section"> <a href="http: ...

Guide on incorporating a Python script into a website using DJango

I am new to Django and looking for guidance. My goal is to have users input text in an HTML textbox, then process that text using Python and display it on the website. Despite going through documentation and tutorials, I have not been successful in gettin ...

Acquiring administrative authorization upon user login with PHP

I have developed a registration form and a login form using PHP. However, whenever I run this code, it displays the message "invalid username" when the username is invalid, or it says "your account isn't approved by admin yet." Can anyone please guide ...

Slice the towering text in half lengthwise

Ensure that the last line of visible text fits within a 20px padding, or else it should be completely cut off. The challenge lies in the varying text lengths of h3 each time. It's difficult to predict how much needs to be trimmed. Currently, the tex ...

Avoid placing content before a link to ensure better focus

I came across some CSS code that closely resembles the following code. (I copied it from http://jsfiddle.net/LmvgM/8/ thanks @thirtydot). I noticed that when the link is focused, the :before content is included. Is there a way to remove it from the highli ...

Removing a modal div element in React after navigating

import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axios from "axios"; import Cookies from "js-cookie"; const LoginPage = () => { const [email, setEmail] = useState( ...

Having trouble with Jquery CSS transform not functioning properly in Internet Explorer 8?

When it comes to utilizing CSS3 features that are not supported by older browsers such as IE8, I tend to apply them using jQuery instead. However, I have noticed that the CSS transform in jQuery does not work... Here is my code: http://codepen.io/vincentc ...

Validation on the client side will now support the input of comma-separated values

Is there a way to use the jQuery.validator.addClassRules method in order to validate input fields and restrict my textbox to only accept comma-separated values? I also want it to display a default message if incorrect. <input type="text" cla ...

Adjust SVG size as per parent container in AngularJS custom directive

I have a unique situation where I am integrating an angular directive into a dynamically-sized element. The directive itself is made up of an SVG which adjusts based on the size of the container. I am working on making sure the SVG automatically resizes an ...

Implementing Jquery to Repurpose a Function Numerous Times Using a Single Dynamic Value

Important: I have provided a functional example of the page on my website, currently only functioning for the DayZ section. Check it out here Update: Below is the HTML code for the redditHeader click event <div class="redditHeader grey3"> & ...

What is the best way to format specific text as bold within an input text field?

I am attempting to make certain text bold within an input text field. However, I'm uncertain about how to achieve this because HTML code is not recognized inside a text field. Therefore, using <b> will not be effective. Is there a way to bold sp ...

Show a pop-up when hovering over each row of a Material UI table and address the problem with the box

Working on a react app using React v18.2 and Material UI V5, I successfully created a table with MUI Table component where I want to display a popover for each row when hovered over. To achieve this, I added a simple popover component to the last cell of ...